home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Visual Basic 5.0 (2nd Edition) / Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso / Code / Goodies / ICONWO~1 / ICONEDIT.FRM < prev    next >
Text File  |  1997-06-09  |  112KB  |  2,928 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.Form Editor 
  4.    Caption         =   "IconWorks Editor: 1 - [Untitled]"
  5.    ClientHeight    =   4656
  6.    ClientLeft      =   1296
  7.    ClientTop       =   1836
  8.    ClientWidth     =   6156
  9.    ClipControls    =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   7.8
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H00FFFFFF&
  20.    Icon            =   "ICONEDIT.frx":0000
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    LockControls    =   -1  'True
  24.    PaletteMode     =   1  'UseZOrder
  25.    ScaleHeight     =   388
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   513
  28.    Begin VB.PictureBox Pic_ToolPalette 
  29.       AutoSize        =   -1  'True
  30.       BackColor       =   &H00808080&
  31.       BorderStyle     =   0  'None
  32.       DrawMode        =   6  'Mask Pen Not
  33.       DrawWidth       =   2
  34.       Height          =   3072
  35.       Left            =   0
  36.       Picture         =   "ICONEDIT.frx":030A
  37.       ScaleHeight     =   256
  38.       ScaleMode       =   3  'Pixel
  39.       ScaleWidth      =   32
  40.       TabIndex        =   0
  41.       TabStop         =   0   'False
  42.       Top             =   0
  43.       Visible         =   0   'False
  44.       Width           =   384
  45.    End
  46.    Begin VB.VScrollBar Scrl_Zoom 
  47.       Height          =   3870
  48.       HelpContextID   =   1903
  49.       LargeChange     =   32
  50.       Left            =   480
  51.       Max             =   258
  52.       Min             =   34
  53.       SmallChange     =   32
  54.       TabIndex        =   4
  55.       Tag             =   "9040"
  56.       Top             =   -15
  57.       Value           =   34
  58.       Visible         =   0   'False
  59.       Width           =   270
  60.    End
  61.    Begin VB.PictureBox Pic_Edit 
  62.       Appearance      =   0  'Flat
  63.       BackColor       =   &H000000FF&
  64.       ForeColor       =   &H80000008&
  65.       Height          =   3870
  66.       Left            =   735
  67.       ScaleHeight     =   321
  68.       ScaleMode       =   3  'Pixel
  69.       ScaleWidth      =   321
  70.       TabIndex        =   2
  71.       Tag             =   "9000"
  72.       Top             =   -30
  73.       Visible         =   0   'False
  74.       Width           =   3870
  75.       Begin VB.PictureBox Pic_Mask 
  76.          Appearance      =   0  'Flat
  77.          AutoRedraw      =   -1  'True
  78.          BackColor       =   &H00FFFFFF&
  79.          BorderStyle     =   0  'None
  80.          ForeColor       =   &H00000000&
  81.          Height          =   480
  82.          Left            =   1965
  83.          ScaleHeight     =   40
  84.          ScaleMode       =   3  'Pixel
  85.          ScaleWidth      =   40
  86.          TabIndex        =   6
  87.          TabStop         =   0   'False
  88.          Top             =   945
  89.          Visible         =   0   'False
  90.          Width           =   480
  91.       End
  92.       Begin VB.PictureBox Pic_Image 
  93.          Appearance      =   0  'Flat
  94.          AutoRedraw      =   -1  'True
  95.          BackColor       =   &H00000000&
  96.          BorderStyle     =   0  'None
  97.          ForeColor       =   &H00000000&
  98.          Height          =   480
  99.          Left            =   1380
  100.          ScaleHeight     =   40
  101.          ScaleMode       =   3  'Pixel
  102.          ScaleWidth      =   40
  103.          TabIndex        =   5
  104.          TabStop         =   0   'False
  105.          Top             =   945
  106.          Visible         =   0   'False
  107.          Width           =   480
  108.       End
  109.       Begin VB.PictureBox Pic_Grid 
  110.          Appearance      =   0  'Flat
  111.          AutoRedraw      =   -1  'True
  112.          BackColor       =   &H00FFFFFF&
  113.          BorderStyle     =   0  'None
  114.          ForeColor       =   &H00000000&
  115.          Height          =   480
  116.          Left            =   1380
  117.          ScaleHeight     =   40
  118.          ScaleMode       =   3  'Pixel
  119.          ScaleWidth      =   40
  120.          TabIndex        =   19
  121.          Top             =   1515
  122.          Visible         =   0   'False
  123.          Width           =   480
  124.       End
  125.       Begin VB.PictureBox Pic_Work 
  126.          Appearance      =   0  'Flat
  127.          AutoRedraw      =   -1  'True
  128.          AutoSize        =   -1  'True
  129.          BackColor       =   &H00000000&
  130.          BorderStyle     =   0  'None
  131.          FillStyle       =   0  'Solid
  132.          ForeColor       =   &H00000000&
  133.          Height          =   480
  134.          Left            =   1965
  135.          ScaleHeight     =   40
  136.          ScaleMode       =   3  'Pixel
  137.          ScaleWidth      =   40
  138.          TabIndex        =   14
  139.          TabStop         =   0   'False
  140.          Top             =   1515
  141.          Visible         =   0   'False
  142.          Width           =   480
  143.       End
  144.       Begin VB.PictureBox Pic_TempImage 
  145.          Appearance      =   0  'Flat
  146.          AutoRedraw      =   -1  'True
  147.          BackColor       =   &H00000000&
  148.          BorderStyle     =   0  'None
  149.          ForeColor       =   &H00000000&
  150.          Height          =   480
  151.          Left            =   1380
  152.          ScaleHeight     =   40
  153.          ScaleMode       =   3  'Pixel
  154.          ScaleWidth      =   40
  155.          TabIndex        =   15
  156.          Top             =   2085
  157.          Visible         =   0   'False
  158.          Width           =   480
  159.       End
  160.       Begin VB.PictureBox Pic_TempMask 
  161.          Appearance      =   0  'Flat
  162.          AutoRedraw      =   -1  'True
  163.          BackColor       =   &H00FFFFFF&
  164.          BorderStyle     =   0  'None
  165.          ForeColor       =   &H00000000&
  166.          Height          =   480
  167.          Left            =   1965
  168.          ScaleHeight     =   40
  169.          ScaleMode       =   3  'Pixel
  170.          ScaleWidth      =   40
  171.          TabIndex        =   16
  172.          Top             =   2085
  173.          Visible         =   0   'False
  174.          Width           =   480
  175.       End
  176.       Begin VB.PictureBox Pic_EditTemp 
  177.          Appearance      =   0  'Flat
  178.          AutoRedraw      =   -1  'True
  179.          BackColor       =   &H00FFFFFF&
  180.          ForeColor       =   &H00000000&
  181.          Height          =   480
  182.          Left            =   1680
  183.          ScaleHeight     =   38
  184.          ScaleMode       =   3  'Pixel
  185.          ScaleWidth      =   38
  186.          TabIndex        =   20
  187.          Top             =   2745
  188.          Visible         =   0   'False
  189.          Width           =   480
  190.       End
  191.    End
  192.    Begin VB.PictureBox Pic_StatusArea 
  193.       BackColor       =   &H00C0C0C0&
  194.       BeginProperty Font 
  195.          Name            =   "Courier"
  196.          Size            =   9.6
  197.          Charset         =   0
  198.          Weight          =   700
  199.          Underline       =   0   'False
  200.          Italic          =   0   'False
  201.          Strikethrough   =   0   'False
  202.       EndProperty
  203.       FontTransparent =   0   'False
  204.       ForeColor       =   &H00C0C0C0&
  205.       Height          =   4680
  206.       HelpContextID   =   1904
  207.       Left            =   4590
  208.       ScaleHeight     =   386
  209.       ScaleMode       =   3  'Pixel
  210.       ScaleWidth      =   129
  211.       TabIndex        =   7
  212.       TabStop         =   0   'False
  213.       Tag             =   "9010"
  214.       Top             =   -30
  215.       Visible         =   0   'False
  216.       Width           =   1590
  217.       Begin VB.PictureBox Pic_Icons 
  218.          Appearance      =   0  'Flat
  219.          AutoRedraw      =   -1  'True
  220.          BackColor       =   &H80000005&
  221.          BorderStyle     =   0  'None
  222.          DragIcon        =   "ICONEDIT.frx":138C
  223.          DrawMode        =   4  'Mask Not Pen
  224.          FillStyle       =   0  'Solid
  225.          ForeColor       =   &H80000008&
  226.          Height          =   480
  227.          Index           =   0
  228.          Left            =   210
  229.          Picture         =   "ICONEDIT.frx":1696
  230.          ScaleHeight     =   40
  231.          ScaleMode       =   3  'Pixel
  232.          ScaleWidth      =   40
  233.          TabIndex        =   8
  234.          TabStop         =   0   'False
  235.          Tag             =   "9130"
  236.          Top             =   180
  237.          Width           =   480
  238.       End
  239.       Begin VB.PictureBox Pic_Icons 
  240.          Appearance      =   0  'Flat
  241.          BackColor       =   &H80000005&
  242.          BorderStyle     =   0  'None
  243.          DragIcon        =   "ICONEDIT.frx":19A0
  244.          FillStyle       =   0  'Solid
  245.          ForeColor       =   &H80000008&
  246.          Height          =   480
  247.          Index           =   1
  248.          Left            =   885
  249.          Picture         =   "ICONEDIT.frx":1CAA
  250.          ScaleHeight     =   40
  251.          ScaleMode       =   3  'Pixel
  252.          ScaleWidth      =   40
  253.          TabIndex        =   9
  254.          TabStop         =   0   'False
  255.          Tag             =   "9130"
  256.          Top             =   180
  257.          Width           =   480
  258.       End
  259.       Begin VB.PictureBox Pic_Icons 
  260.          Appearance      =   0  'Flat
  261.          BackColor       =   &H80000005&
  262.          BorderStyle     =   0  'None
  263.          DragIcon        =   "ICONEDIT.frx":1FB4
  264.          FillStyle       =   0  'Solid
  265.          ForeColor       =   &H80000008&
  266.          Height          =   480
  267.          Index           =   2
  268.          Left            =   210
  269.          Picture         =   "ICONEDIT.frx":22BE
  270.          ScaleHeight     =   40
  271.          ScaleMode       =   3  'Pixel
  272.          ScaleWidth      =   40
  273.          TabIndex        =   10
  274.          TabStop         =   0   'False
  275.          Tag             =   "9130"
  276.          Top             =   840
  277.          Width           =   480
  278.       End
  279.       Begin VB.PictureBox Pic_Icons 
  280.          Appearance      =   0  'Flat
  281.          BackColor       =   &H80000005&
  282.          BorderStyle     =   0  'None
  283.          DragIcon        =   "ICONEDIT.frx":25C8
  284.          FillStyle       =   0  'Solid
  285.          ForeColor       =   &H80000008&
  286.          Height          =   480
  287.          Index           =   3
  288.          Left            =   885
  289.          Picture         =   "ICONEDIT.frx":28D2
  290.          ScaleHeight     =   40
  291.          ScaleMode       =   3  'Pixel
  292.          ScaleWidth      =   40
  293.          TabIndex        =   11
  294.          TabStop         =   0   'False
  295.          Tag             =   "9130"
  296.          Top             =   840
  297.          Width           =   480
  298.       End
  299.       Begin VB.PictureBox Pic_Icons 
  300.          Appearance      =   0  'Flat
  301.          BackColor       =   &H80000005&
  302.          BorderStyle     =   0  'None
  303.          DragIcon        =   "ICONEDIT.frx":2BDC
  304.          FillStyle       =   0  'Solid
  305.          ForeColor       =   &H80000008&
  306.          Height          =   480
  307.          Index           =   4
  308.          Left            =   210
  309.          Picture         =   "ICONEDIT.frx":2EE6
  310.          ScaleHeight     =   40
  311.          ScaleMode       =   3  'Pixel
  312.          ScaleWidth      =   40
  313.          TabIndex        =   12
  314.          TabStop         =   0   'False
  315.          Tag             =   "9130"
  316.          Top             =   1500
  317.          Width           =   480
  318.       End
  319.       Begin VB.PictureBox Pic_Icons 
  320.          Appearance      =   0  'Flat
  321.          BackColor       =   &H80000005&
  322.          BorderStyle     =   0  'None
  323.          DragIcon        =   "ICONEDIT.frx":31F0
  324.          FillStyle       =   0  'Solid
  325.          ForeColor       =   &H80000008&
  326.          Height          =   480
  327.          Index           =   5
  328.          Left            =   885
  329.          Picture         =   "ICONEDIT.frx":34FA
  330.          ScaleHeight     =   40
  331.          ScaleMode       =   3  'Pixel
  332.          ScaleWidth      =   40
  333.          TabIndex        =   13
  334.          TabStop         =   0   'False
  335.          Tag             =   "9130"
  336.          Top             =   1500
  337.          Width           =   480
  338.       End
  339.       Begin VB.PictureBox Pic_Undo 
  340.          Appearance      =   0  'Flat
  341.          BackColor       =   &H80000005&
  342.          BorderStyle     =   0  'None
  343.          DragIcon        =   "ICONEDIT.frx":3804
  344.          ForeColor       =   &H80000008&
  345.          Height          =   480
  346.          HelpContextID   =   1902
  347.          Left            =   1035
  348.          Picture         =   "ICONEDIT.frx":3B0E
  349.          ScaleHeight     =   40
  350.          ScaleMode       =   3  'Pixel
  351.          ScaleWidth      =   40
  352.          TabIndex        =   3
  353.          TabStop         =   0   'False
  354.          Tag             =   "9150"
  355.          Top             =   2505
  356.          Width           =   480
  357.       End
  358.       Begin VB.OptionButton Opt_Mouse 
  359.          BackColor       =   &H00C0C0C0&
  360.          Height          =   360
  361.          Index           =   0
  362.          Left            =   690
  363.          TabIndex        =   17
  364.          Tag             =   "9160"
  365.          Top             =   3600
  366.          Value           =   -1  'True
  367.          Width           =   195
  368.       End
  369.       Begin VB.OptionButton Opt_Mouse 
  370.          BackColor       =   &H00C0C0C0&
  371.          Height          =   360
  372.          HelpContextID   =   1901
  373.          Index           =   1
  374.          Left            =   690
  375.          TabIndex        =   1
  376.          Tag             =   "9160"
  377.          Top             =   4200
  378.          Width           =   195
  379.       End
  380.    End
  381.    Begin VB.PictureBox Pic_ColorPalette 
  382.       Height          =   810
  383.       HelpContextID   =   1905
  384.       Left            =   0
  385.       ScaleHeight     =   64
  386.       ScaleMode       =   3  'Pixel
  387.       ScaleWidth      =   380
  388.       TabIndex        =   18
  389.       TabStop         =   0   'False
  390.       Tag             =   "9030"
  391.       Top             =   3840
  392.       Visible         =   0   'False
  393.       Width           =   4605
  394.    End
  395.    Begin MSComDlg.CommonDialog CMDialog1 
  396.       Left            =   15
  397.       Top             =   4140
  398.       _ExtentX        =   847
  399.       _ExtentY        =   847
  400.       _Version        =   327680
  401.       CancelError     =   -1  'True
  402.    End
  403.    Begin VB.Menu Menu_File 
  404.       Caption         =   "&File"
  405.       HelpContextID   =   1100
  406.       Begin VB.Menu Menu_FileSelection 
  407.          Caption         =   "&New"
  408.          HelpContextID   =   1101
  409.          Index           =   0
  410.       End
  411.       Begin VB.Menu Menu_FileSelection 
  412.          Caption         =   "&Open..."
  413.          HelpContextID   =   1102
  414.          Index           =   1
  415.       End
  416.       Begin VB.Menu Menu_FileSelection 
  417.          Caption         =   "&Save"
  418.          HelpContextID   =   1103
  419.          Index           =   2
  420.          Shortcut        =   +{F12}
  421.       End
  422.       Begin VB.Menu Menu_FileSelection 
  423.          Caption         =   "Save &As..."
  424.          HelpContextID   =   1104
  425.          Index           =   3
  426.          Shortcut        =   {F12}
  427.       End
  428.       Begin VB.Menu Menu_FileSelection 
  429.          Caption         =   "-"
  430.          Index           =   4
  431.       End
  432.       Begin VB.Menu Menu_FileSelection 
  433.          Caption         =   "E&xit"
  434.          HelpContextID   =   1105
  435.          Index           =   5
  436.       End
  437.    End
  438.    Begin VB.Menu Menu_Edit 
  439.       Caption         =   "&Edit"
  440.       HelpContextID   =   1200
  441.       Begin VB.Menu Menu_EditSelection 
  442.          Caption         =   "&Undo"
  443.          HelpContextID   =   1201
  444.          Index           =   0
  445.          Shortcut        =   %{BKSP}
  446.       End
  447.       Begin VB.Menu Menu_EditSelection 
  448.          Caption         =   "-"
  449.          Index           =   1
  450.       End
  451.       Begin VB.Menu Menu_EditSelection 
  452.          Caption         =   "Cu&t"
  453.          HelpContextID   =   1202
  454.          Index           =   2
  455.          Shortcut        =   +{DEL}
  456.       End
  457.       Begin VB.Menu Menu_EditSelection 
  458.          Caption         =   "&Copy"
  459.          HelpContextID   =   1203
  460.          Index           =   3
  461.          Shortcut        =   ^{INSERT}
  462.       End
  463.       Begin VB.Menu Menu_EditSelection 
  464.          Caption         =   "&Paste"
  465.          HelpContextID   =   1204
  466.          Index           =   4
  467.          Shortcut        =   +{INSERT}
  468.       End
  469.       Begin VB.Menu Menu_EditSelection 
  470.          Caption         =   "Paste &Opaque"
  471.          HelpContextID   =   1205
  472.          Index           =   5
  473.          Shortcut        =   ^O
  474.       End
  475.       Begin VB.Menu Menu_EditSelection 
  476.          Caption         =   "&Delete"
  477.          HelpContextID   =   1206
  478.          Index           =   6
  479.          Shortcut        =   {DEL}
  480.       End
  481.       Begin VB.Menu Menu_EditSelection 
  482.          Caption         =   "&Select All"
  483.          HelpContextID   =   1207
  484.          Index           =   7
  485.          Shortcut        =   ^A
  486.       End
  487.       Begin VB.Menu Menu_EditSelection 
  488.          Caption         =   "-"
  489.          Index           =   8
  490.       End
  491.       Begin VB.Menu Menu_EditSelection 
  492.          Caption         =   "Flip &Horizontal"
  493.          HelpContextID   =   1208
  494.          Index           =   9
  495.          Shortcut        =   ^H
  496.       End
  497.       Begin VB.Menu Menu_EditSelection 
  498.          Caption         =   "Flip &Vertical"
  499.          HelpContextID   =   1209
  500.          Index           =   10
  501.          Shortcut        =   ^V
  502.       End
  503.       Begin VB.Menu Menu_EditSelection 
  504.          Caption         =   "-"
  505.          Index           =   11
  506.       End
  507.       Begin VB.Menu Menu_EditSelection 
  508.          Caption         =   "Rotate 90  &Right"
  509.          HelpContextID   =   1210
  510.          Index           =   12
  511.          Shortcut        =   ^R
  512.       End
  513.       Begin VB.Menu Menu_EditSelection 
  514.          Caption         =   "Rotate 90  &Left"
  515.          HelpContextID   =   1211
  516.          Index           =   13
  517.          Shortcut        =   ^L
  518.       End
  519.       Begin VB.Menu Menu_EditSelection 
  520.          Caption         =   "-"
  521.          Index           =   14
  522.       End
  523.       Begin VB.Menu Menu_EditSelection 
  524.          Caption         =   "&Invert"
  525.          HelpContextID   =   1212
  526.          Index           =   15
  527.          Shortcut        =   ^I
  528.       End
  529.    End
  530.    Begin VB.Menu Menu_View 
  531.       Caption         =   "&View"
  532.       HelpContextID   =   1300
  533.       Begin VB.Menu Menu_ViewSelection 
  534.          Caption         =   "&Status Area"
  535.          Checked         =   -1  'True
  536.          HelpContextID   =   1301
  537.          Index           =   0
  538.          Shortcut        =   ^S
  539.       End
  540.       Begin VB.Menu Menu_ViewSelection 
  541.          Caption         =   "&Tool Palette"
  542.          Checked         =   -1  'True
  543.          HelpContextID   =   1302
  544.          Index           =   1
  545.          Shortcut        =   ^T
  546.       End
  547.       Begin VB.Menu Menu_ViewSelection 
  548.          Caption         =   "&Color Palette"
  549.          Checked         =   -1  'True
  550.          HelpContextID   =   1303
  551.          Index           =   2
  552.          Shortcut        =   ^C
  553.       End
  554.       Begin VB.Menu Menu_ViewSelection 
  555.          Caption         =   "&Zooming Scroll bar"
  556.          Checked         =   -1  'True
  557.          HelpContextID   =   1304
  558.          Index           =   3
  559.          Shortcut        =   ^Z
  560.       End
  561.       Begin VB.Menu Menu_ViewSelection 
  562.          Caption         =   "Show &All"
  563.          HelpContextID   =   1305
  564.          Index           =   4
  565.       End
  566.       Begin VB.Menu Menu_ViewSelection 
  567.          Caption         =   "-"
  568.          Index           =   5
  569.       End
  570.       Begin VB.Menu Menu_ViewSelection 
  571.          Caption         =   "&Grid"
  572.          HelpContextID   =   1306
  573.          Index           =   6
  574.          Shortcut        =   ^G
  575.       End
  576.       Begin VB.Menu Menu_ViewSelection 
  577.          Caption         =   "&Line Grid"
  578.          HelpContextID   =   1307
  579.          Index           =   7
  580.       End
  581.       Begin VB.Menu Menu_ViewSelection 
  582.          Caption         =   "&Dotted Grid"
  583.          HelpContextID   =   1308
  584.          Index           =   8
  585.       End
  586.       Begin VB.Menu Menu_ViewSelection 
  587.          Caption         =   "-"
  588.          Index           =   9
  589.       End
  590.       Begin VB.Menu Menu_ViewSelection 
  591.          Caption         =   "Zoom &In"
  592.          HelpContextID   =   1309
  593.          Index           =   10
  594.          Shortcut        =   ^{F11}
  595.       End
  596.       Begin VB.Menu Menu_ViewSelection 
  597.          Caption         =   "Zoom &Out"
  598.          HelpContextID   =   1310
  599.          Index           =   11
  600.          Shortcut        =   ^{F12}
  601.       End
  602.       Begin VB.Menu Menu_ViewSelection 
  603.          Caption         =   "-"
  604.          Index           =   12
  605.       End
  606.       Begin VB.Menu Menu_ViewSelection 
  607.          Caption         =   "&Focus to Editor on Drag&&Drop"
  608.          Checked         =   -1  'True
  609.          HelpContextID   =   1311
  610.          Index           =   13
  611.       End
  612.       Begin VB.Menu Menu_ViewSelection 
  613.          Caption         =   "Display &Border on selected Icon"
  614.          Checked         =   -1  'True
  615.          HelpContextID   =   1312
  616.          Index           =   14
  617.       End
  618.       Begin VB.Menu Menu_ViewSelection 
  619.          Caption         =   "&Pop-up Tools menu on Form Click"
  620.          Checked         =   -1  'True
  621.          HelpContextID   =   1313
  622.          Index           =   15
  623.       End
  624.    End
  625.    Begin VB.Menu Menu_Tools 
  626.       Caption         =   "&Tools"
  627.       HelpContextID   =   1400
  628.       Begin VB.Menu Menu_ToolsSelection 
  629.          Caption         =   "&Select"
  630.          HelpContextID   =   1401
  631.          Index           =   0
  632.       End
  633.       Begin VB.Menu Menu_ToolsSelection 
  634.          Caption         =   "&Paint"
  635.          HelpContextID   =   1402
  636.          Index           =   1
  637.       End
  638.       Begin VB.Menu Menu_ToolsSelection 
  639.          Caption         =   "&Fill"
  640.          HelpContextID   =   1403
  641.          Index           =   2
  642.       End
  643.       Begin VB.Menu Menu_ToolsSelection 
  644.          Caption         =   "&Line"
  645.          HelpContextID   =   1404
  646.          Index           =   3
  647.       End
  648.       Begin VB.Menu Menu_ToolsSelection 
  649.          Caption         =   "&Square"
  650.          HelpContextID   =   1405
  651.          Index           =   4
  652.       End
  653.       Begin VB.Menu Menu_ToolsSelection 
  654.          Caption         =   "Filled S&quare"
  655.          HelpContextID   =   1406
  656.          Index           =   5
  657.       End
  658.       Begin VB.Menu Menu_ToolsSelection 
  659.          Caption         =   "&Circle"
  660.          HelpContextID   =   1407
  661.          Index           =   6
  662.       End
  663.       Begin VB.Menu Menu_ToolsSelection 
  664.          Caption         =   "Filled C&ircle"
  665.          HelpContextID   =   1408
  666.          Index           =   7
  667.       End
  668.    End
  669.    Begin VB.Menu Menu_Icons 
  670.       Caption         =   "&Icons"
  671.       HelpContextID   =   1500
  672.       Begin VB.Menu Menu_IconsSelection 
  673.          Caption         =   "&1 - [Untitled]"
  674.          Index           =   0
  675.       End
  676.       Begin VB.Menu Menu_IconsSelection 
  677.          Caption         =   "&2 - [Untitled]"
  678.          Index           =   1
  679.       End
  680.       Begin VB.Menu Menu_IconsSelection 
  681.          Caption         =   "&3 - [Untitled]"
  682.          Index           =   2
  683.       End
  684.       Begin VB.Menu Menu_IconsSelection 
  685.          Caption         =   "&4 - [Untitled]"
  686.          Index           =   3
  687.       End
  688.       Begin VB.Menu Menu_IconsSelection 
  689.          Caption         =   "&5 - [Untitled]"
  690.          Index           =   4
  691.       End
  692.       Begin VB.Menu Menu_IconsSelection 
  693.          Caption         =   "&6 - [Untitled]"
  694.          Index           =   5
  695.       End
  696.    End
  697.    Begin VB.Menu Menu_Color 
  698.       Caption         =   "&Color"
  699.       HelpContextID   =   1600
  700.       Begin VB.Menu Menu_ColorSelection 
  701.          Caption         =   "&Colors..."
  702.          HelpContextID   =   1601
  703.          Index           =   0
  704.       End
  705.       Begin VB.Menu Menu_ColorSelection 
  706.          Caption         =   "&Default Color Palette"
  707.          Checked         =   -1  'True
  708.          HelpContextID   =   1602
  709.          Index           =   1
  710.       End
  711.       Begin VB.Menu Menu_ColorSelection 
  712.          Caption         =   "S&olid Colors Only"
  713.          HelpContextID   =   1603
  714.          Index           =   2
  715.       End
  716.       Begin VB.Menu Menu_ColorSelection 
  717.          Caption         =   "I&NI File Color Palette"
  718.          HelpContextID   =   1604
  719.          Index           =   3
  720.       End
  721.       Begin VB.Menu Menu_ColorSelection 
  722.          Caption         =   "-"
  723.          Index           =   4
  724.       End
  725.       Begin VB.Menu Menu_ColorSelection 
  726.          Caption         =   "&Save Color Palette to INI file"
  727.          HelpContextID   =   1605
  728.          Index           =   5
  729.       End
  730.       Begin VB.Menu Menu_ColorSelection 
  731.          Caption         =   "-"
  732.          Index           =   6
  733.       End
  734.       Begin VB.Menu Menu_ColorSelection 
  735.          Caption         =   "&Left/Right Colors"
  736.          Checked         =   -1  'True
  737.          HelpContextID   =   1606
  738.          Index           =   7
  739.       End
  740.       Begin VB.Menu Menu_ColorSelection 
  741.          Caption         =   "Screen/&Inverse Colors"
  742.          HelpContextID   =   1607
  743.          Index           =   8
  744.       End
  745.    End
  746.    Begin VB.Menu Menu_Brush 
  747.       Caption         =   "&Brush"
  748.       HelpContextID   =   1700
  749.       Begin VB.Menu Menu_BrushSelection 
  750.          Caption         =   "&Small (1 x 1)"
  751.          Checked         =   -1  'True
  752.          HelpContextID   =   1701
  753.          Index           =   1
  754.       End
  755.       Begin VB.Menu Menu_BrushSelection 
  756.          Caption         =   "&Medium (3 x 3)"
  757.          HelpContextID   =   1702
  758.          Index           =   3
  759.       End
  760.       Begin VB.Menu Menu_BrushSelection 
  761.          Caption         =   "&Large (5 x 5)"
  762.          HelpContextID   =   1703
  763.          Index           =   5
  764.       End
  765.    End
  766.    Begin VB.Menu Menu_Help 
  767.       Caption         =   "&Help"
  768.       Begin VB.Menu Menu_HelpSelection 
  769.          Caption         =   "&Index"
  770.          Index           =   1
  771.       End
  772.       Begin VB.Menu Menu_HelpSelection 
  773.          Caption         =   "&Keyboard"
  774.          Index           =   2
  775.       End
  776.       Begin VB.Menu Menu_HelpSelection 
  777.          Caption         =   "&Commands"
  778.          Index           =   3
  779.       End
  780.       Begin VB.Menu Menu_HelpSelection 
  781.          Caption         =   "&Using Help"
  782.          Index           =   4
  783.       End
  784.       Begin VB.Menu Menu_HelpSelection 
  785.          Caption         =   "-"
  786.          Index           =   5
  787.       End
  788.       Begin VB.Menu Menu_HelpSelection 
  789.          Caption         =   "&About..."
  790.          Index           =   6
  791.       End
  792.    End
  793. End
  794. Attribute VB_Name = "Editor"
  795. Attribute VB_GlobalNameSpace = False
  796. Attribute VB_Creatable = False
  797. Attribute VB_PredeclaredId = True
  798. Attribute VB_Exposed = False
  799. DefInt A-G, I-Z
  800. DefLng H
  801.  
  802. ' When the View.Grid option is selected or deselected, this routine
  803. ' performs the neccessary checking, unchecking of the Grid menu item
  804. ' and Enables or disables the Grid type menu items appropriately,
  805. ' and creates the Grid if selected.
  806. Private Sub Activate_Grid()
  807.     Menu_ViewSelection(MID_GRID).Checked = Not Menu_ViewSelection(MID_GRID).Checked
  808.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  809.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  810.     If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  811.     Magnify_Icon 0, 0, 31, 31
  812. End Sub
  813.  
  814. Private Sub Adjust_Color_Palette()
  815.     ' Determine if Editor is large enough for ColorPalette
  816.     If (ScaleHeight < (Pic_ColorPalette.Height + 34)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  817.         Menu_ViewSelection(MID_COLOR_PALETTE).Checked = False
  818.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = False
  819.     Else
  820.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = True
  821.         ' Check if the ColorPalette is selected to be displayed.
  822.         If Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  823.             NewTop = ScaleHeight - Pic_ColorPalette.Height
  824.             NewWidth = ScaleWidth
  825.             ' Check if the StatusArea is currently displayed, since the StatusArea
  826.             ' affects the width of the ColorPalette.
  827.             If Menu_ViewSelection(MID_STATUS_BAR).Checked Then NewWidth = NewWidth - Pic_StatusArea.Width + 1
  828.             ' Reposition and Resize the ColorPalette.
  829.             Pic_ColorPalette.Move Pic_ColorPalette.Left, NewTop, NewWidth
  830.         End If
  831.     End If
  832. End Sub
  833.  
  834. ' When the Editor is Resized, the the Zoom Scrollbar must be resized,
  835. ' repositioned.  This routine performs the neccessary repositioning
  836. ' for the Zoom Scrollbar.
  837. '
  838. Private Sub Adjust_ScrollBar()
  839.     If Menu_ViewSelection(MID_TOOL_PALETTE).Checked Then NewLeft = Pic_ToolPalette.Width Else NewLeft = -1
  840.     NewHeight = ScaleHeight + 2 + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height
  841.     NewMax = ScaleWidth - (NewLeft - Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width) + 3 + (Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width)
  842.     ' Set the new Max value to the smaller of the NewHeight and the NewMax value.
  843.     If NewMax > NewHeight Then NewMax = NewHeight
  844.     ' We must adjust the New Max value obtained above so it is a multiple of 32.
  845.     While (NewMax - 2) Mod 32
  846.         NewMax = NewMax - 1
  847.     Wend
  848.     Scrl_Zoom.Move NewLeft, Scrl_Zoom.Top, Scrl_Zoom.Width, NewHeight
  849.     Scrl_Zoom.Max = NewMax
  850.     ' Determine if current size of the Editing area is larger than the new maximum size.
  851.     If Pic_Edit.Height > Scrl_Zoom.Max Then
  852.         Scrl_Zoom.Value = Scrl_Zoom.Max
  853.     Else
  854.         Scrl_Zoom_Change
  855.     End If
  856. End Sub
  857.  
  858. ' When the Editor is Resized, the the StatusArea must be resized, and hidden if necessary
  859. Private Sub Adjust_Status_Bar()
  860.     ' Determine if Editor is large enough for StatusArea
  861.     If ((ScaleHeight < (Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT)) Or (ScaleWidth < 2 * Pic_StatusArea.Width)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  862.         Menu_ViewSelection(MID_STATUS_BAR).Checked = False
  863.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = False
  864.     Else
  865.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = True
  866.         If Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  867.             OldHeight = Pic_StatusArea.Height
  868.             Pic_StatusArea.Move ScaleWidth - Pic_StatusArea.Width + 1, Pic_StatusArea.Top, Pic_StatusArea.Width, ScaleHeight + 2
  869.             NewTop = Pic_StatusArea.ScaleHeight - 4.25 * Opt_Mouse(0).Height
  870.             Opt_Mouse(0).Top = NewTop + 1.25 * Opt_Mouse(0).Height
  871.             Opt_Mouse(1).Top = NewTop + 3 * Opt_Mouse(0).Height
  872.             Visibility = NewTop >= (Pic_Icons(5).Top + Pic_Icons(5).Height + 2 * HIGHLIGHT + 4)
  873.             Opt_Mouse(0).Visible = Visibility
  874.             Opt_Mouse(1).Visible = Visibility
  875.             ' Determine if there is room to display the Undo Icon
  876.             If Opt_Mouse(0).Visible Then
  877.                 Pic_Undo.Visible = NewTop >= (Pic_Undo.Top + Pic_Undo.Height)
  878.             Else
  879.                 Pic_Undo.Visible = (Pic_Undo.Top + Pic_Undo.Height) <= Pic_StatusArea.ScaleHeight
  880.             End If
  881.             ' We only want to force it to repaint if its size has changed
  882.             If OldHeight <> Pic_StatusArea.Height Then Pic_StatusArea.Refresh
  883.         End If
  884.     End If
  885.  
  886. End Sub
  887.  
  888. ' When the Editor is Resized, the the ToolPalette may need to be hidden.
  889. Private Sub Adjust_Tool_Palette()
  890.     If ((ScaleHeight < (Pic_ToolPalette.Height + Pic_ColorPalette.Height)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked) Or ((ScaleHeight < Pic_ToolPalette.Height) And (Not Menu_ViewSelection(MID_COLOR_PALETTE).Checked)) Then
  891.         Menu_ViewSelection(MID_TOOL_PALETTE).Checked = False
  892.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = False
  893.     Else
  894.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = True
  895.     End If
  896. End Sub
  897.  
  898. ' To make magnified pixels appear more like single pixels when working
  899. ' with the various tools, this routine is used to adjust the actual pixel
  900. ' clicked to the Center or to the Edge of the selected magnified pixel.
  901. Private Sub Adjust_X_and_Y(X As Single, Y As Single, NewX, NewY, Adjustment)
  902.     Select Case Adjustment
  903.         Case TO_CENTER
  904.             NewX = (X \ PixelSize) * PixelSize + (PixelSize \ 2)
  905.             NewY = (Y \ PixelSize) * PixelSize + (PixelSize \ 2)
  906.         Case TO_EDGE
  907.             Xpix = X \ PixelSize
  908.             Ypix = Y \ PixelSize
  909.             If (X Mod PixelSize) >= (PixelSize / 2) Then Xpix = Xpix + 1
  910.             If (Y Mod PixelSize) >= (PixelSize / 2) Then Ypix = Ypix + 1
  911.             NewX = Xpix * PixelSize
  912.             NewY = Ypix * PixelSize
  913.     End Select
  914. End Sub
  915.  
  916. ' This routine is called when ever the selection is to be comitted to the Icon.
  917. Private Sub Commit_Selection(ResetFlags)
  918.     ' Erase the Rectangle highlighting the selection
  919.     If Selecting Then Draw_Selection_Rectangle
  920.     Scale_Region True, X1, Y1, X2, Y2, True
  921.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  922.     w = X2 - X1
  923.     H = Y2 - Y1
  924.     If Opaque Then
  925.         ' An exact copy of Mask and Image of the Selection are copied
  926.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  927.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  928.     Else
  929.         ' Only the Foreground colors are copied.
  930.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  931.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, H, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCINVERT)
  932.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, H, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  933.     End If
  934.     If ResetFlags Then
  935.         Selecting = False
  936.         MovingSelection = False
  937.     End If
  938.     ' Replace the Icons current Mask and Image bitmaps with the new ones.
  939.     Update_Icon Pic_Icons(CurrentIcon)
  940. End Sub
  941.  
  942. ' This routine is called either in response to an Edit.Cut or Edit.Copy
  943. Private Sub Copy_Selection_To_ClipBoard(X1, Y1, X2, Y2)
  944.     Scale_Region True, X1, Y1, X2, Y2, True
  945.     Pic_Work.Picture = LoadPicture()
  946.     Pic_Work.Move Pic_Work.Left, Pic_Work.Top, X2 - X1, Y2 - Y1
  947.     R = BitBlt(Pic_Work.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Icons(CurrentIcon).hDC, X1, Y1, SRCCOPY)
  948.     Clipboard.Clear
  949.     Clipboard.SetData Pic_Work.Image
  950. End Sub
  951.  
  952. ' The Grid is drawn on a separate Picture control with a White BackGround and
  953. ' Black Foreground, and is only drawn once.  When a piece of the
  954. ' grid is to be redisplayed, the part of the Grid that corresponds
  955. ' to the area of the Icon that needs to be updated is BitBlt'd
  956. ' from the Picture of the Grid over the top of the Displayed Icon,
  957. ' Using the SCRAND raster operation.
  958. Private Sub Create_Grid()
  959.     Pic_Grid.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  960.     Pic_Grid.Cls
  961.     If Menu_ViewSelection(MID_LINE_GRID).Checked Then
  962.         For i = 1 To 31
  963.             Pic_Grid.Line (0, i * PixelSize)-(Pic_Grid.ScaleWidth, i * PixelSize)
  964.             Pic_Grid.Line (i * PixelSize, 0)-(i * PixelSize, Pic_Grid.ScaleHeight)
  965.         Next i
  966.     Else
  967.         For Y = 0 To 31
  968.             For X = 0 To 31
  969.                 Pic_Grid.PSet ((X * PixelSize) + (PixelSize \ 2), (Y * PixelSize) + (PixelSize \ 2))
  970.             Next X
  971.         Next Y
  972.     End If
  973. End Sub
  974.  
  975. ' This routine is called in response to an Edit.Cut, Copy, or
  976. ' Delete menu selection.
  977. Private Sub Cut_Copy_Or_Delete_Selection(Index)
  978.     If Index = MID_DELETE Then
  979.         Scale_Region True, X1, Y1, X2, Y2, True
  980.     Else
  981.         Copy_Selection_To_ClipBoard X1, Y1, X2, Y2
  982.     End If
  983.     If Index <> MID_COPY Then
  984.         Delete_Selection_From_Icon
  985.         Selecting = False
  986.         Magnify_Icon X1, Y1, X2, Y2
  987.     End If
  988. End Sub
  989.  
  990. ' This routine is called either in response to an Edit.Cut or Edit.Delete
  991. Private Sub Delete_Selection_From_Icon()
  992.     Scale_Region True, X1, Y1, X2, Y2, True
  993.     Pic_Image.Line (X1, Y1)-(X2 - 1, Y2 - 1), BLACK, BF
  994.     Pic_Mask.Line (X1, Y1)-(X2 - 1, Y2 - 1), WHITE, BF
  995.     Update_Icon Pic_Icons(CurrentIcon)
  996. End Sub
  997.  
  998. ' This routine is called to display the mouse coordinates.  The
  999. ' coordinates are that of the magnified pixels, not the screen
  1000. ' coordinates, thus, regardless of the magnification of the Icon,
  1001. ' the coordinates will all range from 0-31.
  1002. Private Sub Display_Mouse_Coordinates(Xpix, Ypix)
  1003.     If (Xpix >= 0) And (Xpix <= 31) Then
  1004.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.25
  1005.         Pic_StatusArea.Print Space$(Abs(Xpix < 10)) + Format$(Xpix);
  1006.     End If
  1007.     If (Ypix >= 0) And (Ypix <= 31) Then
  1008.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.75
  1009.         Pic_StatusArea.Print Space$(Abs(Ypix < 10)) + Format$(Ypix);
  1010.     End If
  1011. End Sub
  1012.  
  1013. ' The routine is called to display
  1014. ' the Line or Box for the above tools when requested.
  1015. Private Sub Draw_Line_Or_Box()
  1016.     If CurrentTool = TID_LINE Then
  1017.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region)
  1018.     Else
  1019.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region), , B
  1020.     End If
  1021. End Sub
  1022.  
  1023. ' Since Windows INItialization files only allow the writing string information,
  1024. ' the Color Palette color values are stored in 3 strings, 1 for each row of the
  1025. ' color palette.  This routine is called to extract these color values from
  1026. ' the strings and assign them to the Long Integer Color array.
  1027. Private Sub Extract_Colors_From_String(ColorString As String, FirstColor, RefreshPalette)
  1028.     N = 1
  1029.     For C = FirstColor To FirstColor + 15
  1030.         i = InStr(N, ColorString, " ")
  1031.         If i = 0 Then i = Len(ColorString) + 1
  1032.         Colors(C) = Val(Mid$(ColorString, N, i - N))
  1033.         N = i + 1
  1034.     Next C
  1035.     If RefreshPalette Then
  1036.         Display_Color_Palette Pic_ColorPalette
  1037.         If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  1038.     End If
  1039. End Sub
  1040.  
  1041. ' This routine performs a Surface Flood fill of the selected area
  1042. ' within the Icon when the Fill tool is in use.  The Mask color
  1043. ' of all pixels that are different is then compare to the Mask
  1044. ' color of the original starting Pixel.  If the Mask colors are the
  1045. ' same the Pixel should be changed, otherwise it is unchanged.
  1046. Private Sub Fill_Tool_MouseUp(X As Single, Y As Single, X2, Y2)
  1047. Dim MaskColor As Long, NewPixelColor As Long
  1048.     If (Abs(X) >= 0) And (Abs(X) <= Pic_Edit.ScaleWidth) And (Abs(Y) >= 0) And (Abs(Y) <= Pic_Edit.ScaleHeight) Then
  1049.         Screen.MousePointer = HOURGLASS
  1050.         Xpixel = X \ PixelSize
  1051.         Ypixel = Y \ PixelSize
  1052.         MaskColor = Pic_Mask.Point(Xpixel, Ypixel)
  1053.         Pic_Work.FillColor = Pic_Edit.ForeColor
  1054.         Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  1055.         R = ExtFloodFill(Pic_Work.hDC, Xpixel, Ypixel, Pic_Icons(CurrentIcon).Point(Xpixel, Ypixel), FLOODFILLSURFACE)
  1056.         For Ypix = 0 To 31
  1057.             For Xpix = 0 To 31
  1058.                 NewPixelColor = Pic_Work.Point(Xpix, Ypix)
  1059.                 If (Pic_Icons(CurrentIcon).Point(Xpix, Ypix) <> NewPixelColor) And (Pic_Mask.Point(Xpix, Ypix) = MaskColor) Then
  1060.                     '
  1061.                     ' Pixel was changed by the FloodFill and its Mask matched that of the
  1062.                     ' starting Pixel, so we make the change on the Icons Image and Mask
  1063.                     '
  1064.                     If Opt_Mouse(SCREEN_COLORS).Value Then NewPixelColor = Pic_Image.ForeColor
  1065.                     Pic_Image.PSet (Xpix, Ypix), NewPixelColor
  1066.                     Pic_Mask.PSet (Xpix, Ypix)
  1067.                 End If
  1068.             Next Xpix
  1069.         Next Ypix
  1070.         Screen.MousePointer = DEFAULT
  1071.         X2 = 31
  1072.         Y2 = 31
  1073.     End If
  1074. End Sub
  1075.  
  1076. ' This routine Flips (Mirrors) the current Selection either
  1077. ' Horizontally or Vertically.   The Windows API StretchBlt()
  1078. ' routine is used to perform the Flip operation.
  1079. Private Sub Flip_Selection(Index)
  1080.     w = X2SelectFrom - X1SelectFrom
  1081.     H = Y2SelectFrom - Y1SelectFrom
  1082.     If Index = MID_FLIP_HORIZONTAL Then
  1083.         DestX = X2SelectFrom - 1
  1084.         DestY = Y1SelectFrom
  1085.         DestWidth = -w
  1086.         DestHeight = H
  1087.     Else
  1088.         DestX = X1SelectFrom
  1089.         DestY = Y2SelectFrom - 1
  1090.         DestWidth = w
  1091.         DestHeight = -H
  1092.     End If
  1093.     R = StretchBlt(Pic_TempImage.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, w, H, SRCCOPY)
  1094.     R = StretchBlt(Pic_TempMask.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, w, H, SRCCOPY)
  1095.     R = StretchBlt(Pic_Work.hDC, DestX, DestY, DestWidth, DestHeight, Pic_Work.hDC, X1SelectFrom, Y1SelectFrom, w, H, SRCCOPY)
  1096.     Scale_Region True, X1, Y1, X2, Y2, False
  1097.     If Not MovingSelection Then Commit_Selection False
  1098.     Magnify_Icon X1, Y1, X2, Y2
  1099. End Sub
  1100.  
  1101.  
  1102.  
  1103. Private Sub Form_Load()
  1104.  
  1105.     ' Determine color mode and set Icons Image bitmap size accordingly
  1106.     ' This value, ImageSize, is used within the routines Update_Icon and
  1107.     ' Extract_Image_And_Mask within ICONWRKS.BAS
  1108.     '
  1109.     If GetDeviceCaps(hDC, BITSPIXEL) = 8 Then
  1110.         ImageSize = 1024 'bytes
  1111.     Else
  1112.         ImageSize = 512  'bytes
  1113.     End If
  1114.  
  1115.     ' Depending on the Video mode and video driver being used for Windows,
  1116.     ' the controls on a form might not be the same dimensions when loaded
  1117.     ' under differenct resolutions.  Since the Editor is based on a
  1118.     ' 32x32 pixel Icon, the Picture controls that are used to manipulate
  1119.     ' the icons must be set at runtime to 32x32.
  1120.     '
  1121.     ' Position and size Icon within StatusArea
  1122.     '
  1123.     Edge = (Pic_StatusArea.ScaleWidth - 64) \ 3
  1124.     For Y = 0 To 2
  1125.         For X = 0 To 1
  1126.             Pic_Icons(X + Y * 2).Move Edge + X * (32 + Edge), Edge + Y * (32 + Edge), 32, 32
  1127.         Next X
  1128.     Next Y
  1129.  
  1130.     Pic_Mask.Move 0, 0, 32, 32
  1131.     Pic_Image.Move 0, 0, 32, 32
  1132.     Pic_TempMask.Move 0, 0, 32, 32
  1133.     Pic_TempImage.Move 0, 0, 32, 32
  1134.     Pic_Work.Move 0, 0, 32, 32
  1135.     Pic_Grid.Move 0, 0, 32, 32
  1136.     Pic_ToolPalette.Move 0, 0, 32, 256
  1137.     Pic_Undo.Move Pic_StatusArea.ScaleWidth - 34, (Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + 2.5 * HIGHLIGHT), 32, 32
  1138.     
  1139.     Get_INI_File_Settings
  1140.  
  1141.     ' Adjust size of Editor appropriately for the Video mode.
  1142.     '
  1143.     
  1144.     If Screen.Height = EGA_HEIGHT Then
  1145.         '
  1146.         ' EGA mode
  1147.         '
  1148.         
  1149.         NewWidth = Width
  1150.         NewHeight = Screen.Height
  1151.         NewTop = 0
  1152.     Else
  1153.         ' VGA or Better
  1154.         '
  1155.         NewWidth = Screen.Width * 0.75
  1156.         NewHeight = Screen.Height * 0.75
  1157.         NewTop = (Screen.Height - NewHeight) \ 2
  1158.     End If
  1159.     Move (Screen.Width - NewWidth) \ 2, NewTop, NewWidth, NewHeight
  1160.  
  1161.     ' Icon is initially displayed at full maginification
  1162.     '
  1163.     Scrl_Zoom.Value = Scrl_Zoom.Max
  1164.  
  1165.     ' Create Monochrome Hdc and Bitmap to be used when replace the
  1166.     ' Icons Monochrome Mask.
  1167.     '
  1168.     hDCMono = CreateCompatibleDC(hDC)
  1169.     hBMMono = CreateCompatibleBitmap(hDCMono, 32, 32)
  1170.     hBMOldMono = SelectObject(hDCMono, hBMMono)
  1171.  
  1172.     ' The BackColor of the Editing area picture control, Pic_Edit,
  1173.     ' is set to Red at design time just so the picture controls contained
  1174.     ' within it are visible at design time.
  1175.     '
  1176.     Pic_Edit.BackColor = WHITE
  1177.  
  1178.     ' Select initial tool and brushsize
  1179.     '
  1180.     CurrentTool = TID_PAINT
  1181.     BrushSize = 1
  1182.   
  1183.     ' Initialize Default Mouse Colors
  1184.     '
  1185.     MouseColors(0) = BLACK  'Left
  1186.     MouseColors(1) = RED    'Right
  1187.     MouseColors(2) = WHITE  'Screen
  1188.     MouseColors(3) = BLACK  'Inverse
  1189.  
  1190.     ' Add Accelerators that are not available from the Menu Design window
  1191.     ' to the appropriate menu items.
  1192.     '
  1193.     Menu_FileSelection(MID_EXIT).Caption = "E&xit" + A_TAB + "Alt+F4"
  1194.     'Menu_EditSelection(MID_UNDO).Caption = "&Undo" + A_TAB + "Alt+Bksp"
  1195.     'Menu_EditSelection(MID_CUT).Caption = "Cu&t" + A_TAB + "Shift+Del"
  1196.     'Menu_EditSelection(MID_COPY).Caption = "&Copy" + A_TAB + "Ctrl+Ins"
  1197.     'Menu_EditSelection(MID_PASTE).Caption = "&Paste" + A_TAB + "Shift+Ins"
  1198.     'Menu_EditSelection(MID_PASTE_OPAQUE).Caption = "Paste &Opaque" + A_TAB + "Ctrl+Shift+Ins"
  1199.     'Menu_EditSelection(MID_DELETE).Caption = "&Delete" + A_TAB + "Del"
  1200.  
  1201.     ' Initialize all 6 Icons filename to UNTITLED, so a File.Save opertion
  1202.     ' will react just like a File.Save As, the first time.
  1203.     '
  1204.     For i = 0 To 5
  1205.       ICONINFO(i).FileName = UNTITLED
  1206.     Next i
  1207.     
  1208.     EditorLoaded = True
  1209.  
  1210. End Sub
  1211.  
  1212. ' Just for an added convience when selecting tools, Clicking anywhere
  1213. ' on the Editor that is not covered by another control, will display
  1214. ' the Tools menu as a pupup menu at that location.
  1215. '
  1216. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1217.  
  1218.     ' Menu is displayed on if the left button is used.
  1219.     '
  1220.     If (Button = RIGHT_BUTTON) And Menu_ViewSelection(MID_POPUP_MENU).Checked Then
  1221.         '
  1222.         ' The X and Y coordintes passed to the TrackPopupMenu() API routine
  1223.         ' are Screen coordinates in pixels, not Form coordinates, so, the
  1224.         ' X and Y coordinates of the Mouse must be adjusted, taking into
  1225.         ' account the position of the form.  And for a little more added
  1226.         ' convience, another adjustment is made so when the menu pops up,
  1227.         ' the mouse poiner is directly over the currently selected tool.
  1228.         '
  1229.         InPixels = ScaleWidth
  1230.         ScaleMode = TWIPS
  1231.         TwipsToPixels = ScaleWidth \ InPixels
  1232.         Borders = (Width - ScaleWidth)
  1233.         TitleBarAndMenu = (Height - ScaleHeight - Borders)
  1234.         IX = X + (Left \ TwipsToPixels)
  1235.         IY = Y + (Top + TitleBarAndMenu - CurrentTool * (TitleBarAndMenu \ 2)) \ TwipsToPixels
  1236.         ScaleMode = PIXELS
  1237.         Menu_ToolsSelection(CurrentTool).Checked = True
  1238.         R = TrackPopupMenu(GetSubMenu(GetMenu(hWnd), 3), 0, IX, IY, 0, hWnd, 0)
  1239.     End If
  1240.  
  1241. End Sub
  1242.  
  1243. ' Resizing of the Editor can, depending on the new size, force any
  1244. ' of the palettes to be hidden, so all major controls must be
  1245. ' resized, repositioned and possibly hidden in reponse to resizing
  1246. ' the Editor.
  1247. '
  1248. Private Sub Form_Resize()
  1249. Static LastWindowState
  1250.  
  1251.     ' Nothing is done if the Editor is minimized.
  1252.     '
  1253.     If WindowState = MINIMIZED Then
  1254.         '
  1255.         ' Hide ColorPalette since it should not be visible while the
  1256.         ' Editor is Minimized.
  1257.         '
  1258.         If ColorPaletteLoaded Then ColorPalette.Hide
  1259.  
  1260.     ElseIf ScaleHeight >= 34 Then
  1261.         '
  1262.         ' Hide the Editing area while resizing other controls
  1263.         ' to prevent uneccessary repaints.
  1264.         '
  1265.         Pic_Edit.Visible = False
  1266.  
  1267.         ' Adjust all major controls
  1268.         '
  1269.         Adjust_Status_Bar
  1270.         Adjust_Tool_Palette
  1271.         Adjust_Color_Palette
  1272.         Adjust_ScrollBar
  1273.     
  1274.         ' Hide or Show the major controls, based on their corresponding View
  1275.         ' menu item Checked value, which was set within the above *Adjust*
  1276.         ' routines.
  1277.         '
  1278.         Pic_ColorPalette.Visible = Menu_ViewSelection(MID_COLOR_PALETTE).Checked
  1279.         Pic_ToolPalette.Visible = Menu_ViewSelection(MID_TOOL_PALETTE).Checked
  1280.         Pic_StatusArea.Visible = Menu_ViewSelection(MID_STATUS_BAR).Checked
  1281.         Scrl_Zoom.Visible = Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked
  1282.         
  1283.         If (LastWindowState = MINIMIZED) And ColorPaletteLoaded Then ColorPalette.Show
  1284.  
  1285.     End If
  1286.  
  1287.     LastWindowState = WindowState
  1288.  
  1289. End Sub
  1290.  
  1291. ' Editor is being terminated
  1292. '
  1293. Private Sub Form_Unload(Cancel As Integer)
  1294.     
  1295.     ' Check fo any icons that have been modified since they
  1296.     ' were last saved.
  1297.     '
  1298.     Text = ""
  1299.     For i = 0 To 5
  1300.         If ICONINFO(i).Changed Then Text = Text + "Icon #" + Right$(Menu_IconsSelection(i).Caption, Len(Menu_IconsSelection(i).Caption) - 1) + CRLF
  1301.     Next i
  1302.     
  1303.     If Text <> "" Then
  1304.         '
  1305.         ' One or more icons were changed, so prompt user.
  1306.         '
  1307.         Text = Text + CRLF + "The icons listed have not been saved since their last modification.  Quit anyway?"
  1308.         Cancel = MsgBox(Text, 36, "ICONS HAVE CHANGED") = MBNO
  1309.     End If
  1310.  
  1311.     If Not Cancel Then
  1312.         '
  1313.         ' User wants to terminate Editor, so clean up.
  1314.         '
  1315.         EditorLoaded = False
  1316.         Unload ColorPalette
  1317.         SelectObject hBMMono, hBMOldMono
  1318.         DeleteObject hBMMono
  1319.         DeleteDC hDCMono
  1320.         WinHelp hWnd, dummy$, HELP_QUIT, 0
  1321.         Save_Settings_To_INI_File
  1322.         '
  1323.         ' If Editor was started up first (Null command line or anything other than
  1324.         ' "v" or "V") then we treat it as the main Form.  So, if the Viewer is loaded,
  1325.         ' we should as the user if the Viewer should also be terminated.
  1326.         '
  1327.         If (MainForm = ICONWORKS_EDITOR) And ViewerLoaded Then
  1328.             '
  1329.             ' Editor was started first and the Viewer is loaded so ask the user
  1330.             ' if the Viewer should also be terminated.
  1331.             '
  1332.             Text = "Terminate Viewer also?"
  1333.             If MsgBox(Text, 36, "IconWorks") = MBYES Then Unload Viewer
  1334.             MainForm = ICONWORKS_VIEWER
  1335.         End If
  1336.     End If
  1337.  
  1338. End Sub
  1339.  
  1340. ' In response to a MouseDown event in the Edit area, the first thing
  1341. ' that must be done is deterine what color to use when drawing the object.
  1342. Private Sub Get_Current_Colors(Button As Integer)
  1343. Dim Index As Integer
  1344.     ' Determine which of the 4 currently selected colors to use, and
  1345.     ' assign to the Edit area's foreground color.
  1346.     Index = Opt_Mouse(SCREEN_COLORS).Value * (-2) + Button - 1
  1347.     Pic_Edit.ForeColor = MouseColors(Index)
  1348.     ' If using the Paint tool, we must use the Neaest Solid color to the selected color.
  1349.     If CurrentTool = TID_PAINT Then Pic_Edit.ForeColor = GetNearestColor(hDC, Pic_Edit.ForeColor)
  1350.     If Opt_Mouse(MOUSE_COLORS).Value Then
  1351.         Pic_Image.ForeColor = Pic_Edit.ForeColor
  1352.     Else
  1353.         Pic_Image.ForeColor = (Button = RIGHT_BUTTON) And WHITE
  1354.     End If
  1355.     Pic_Mask.ForeColor = Opt_Mouse(SCREEN_COLORS).Value And WHITE
  1356.     Pic_Image.FillColor = Pic_Image.ForeColor
  1357.     Pic_Mask.FillColor = Pic_Mask.ForeColor
  1358.     Pic_Edit.FillColor = Pic_Edit.ForeColor
  1359. End Sub
  1360.  
  1361. ' This routine is called to read the color value strings from
  1362. ' the IconWrks.INI file, and then have The values extracted
  1363. Private Sub Get_INI_File_Colors()
  1364.     ColorString = Space$(144)
  1365.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "1", DEFAULT_COLORS_ROW1, ColorString, Len(ColorString), INI_FILENAME)
  1366.     Extract_Colors_From_String ColorString, 0, False
  1367.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "2", DEFAULT_COLORS_ROW2, ColorString, Len(ColorString), INI_FILENAME)
  1368.     Extract_Colors_From_String ColorString, 16, False
  1369.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "3", DEFAULT_COLORS_ROW3, ColorString, Len(ColorString), INI_FILENAME)
  1370.     Extract_Colors_From_String ColorString, 32, True
  1371. End Sub
  1372.  
  1373. ' This routine is called only once, which is at load time to obtain
  1374. ' all settings saved to the IconWrks.INI file.
  1375. Private Sub Get_INI_File_Settings()
  1376. Dim Index As Integer
  1377.     Menu_ViewSelection(MID_STATUS_BAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_STATUS_BAR, 1, INI_FILENAME)
  1378.     Menu_ViewSelection(MID_TOOL_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_TOOL_PALETTE, 1, INI_FILENAME)
  1379.     Menu_ViewSelection(MID_COLOR_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_COLOR_PALETTE, 1, INI_FILENAME)
  1380.     Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_ZOOM_SCROLLBAR, 1, INI_FILENAME)
  1381.     Menu_ViewSelection(MID_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_GRID, 0, INI_FILENAME)
  1382.     Menu_ViewSelection(MID_LINE_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_LINE_GRID, 1, INI_FILENAME)
  1383.     Menu_ViewSelection(MID_DOTTED_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DOTTED_GRID, 0, INI_FILENAME)
  1384.     Menu_ViewSelection(MID_FOCUS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_FOCUS, 1, INI_FILENAME)
  1385.     Menu_ViewSelection(MID_BORDER).Checked = -GetPrivateProfileInt(APP_NAME, KEY_BORDER, 1, INI_FILENAME)
  1386.     Menu_ViewSelection(MID_POPUP_MENU).Checked = -GetPrivateProfileInt(APP_NAME, KEY_POPUP, 1, INI_FILENAME)
  1387.     ' Get all Checked Color Menu item values
  1388.     Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DEFAULT, 1, INI_FILENAME)
  1389.     Menu_ColorSelection(MID_SOLID_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_SOLID, 0, INI_FILENAME)
  1390.     Menu_ColorSelection(MID_INI_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_INI, 0, INI_FILENAME)
  1391.     ' Enable or Disable the Grid type menu items based on the Check value
  1392.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1393.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1394.     ' Set initial color palette
  1395.     If Menu_ColorSelection(MID_DEFAULT_COLORS).Checked Then Index = MID_DEFAULT_COLORS
  1396.     If Menu_ColorSelection(MID_SOLID_COLORS).Checked Then Index = MID_SOLID_COLORS
  1397.     If Menu_ColorSelection(MID_INI_COLORS).Checked Then Index = MID_INI_COLORS
  1398.     Menu_ColorSelection_Click Index
  1399. End Sub
  1400.  
  1401. ' In response to an Edit.Invert menu item selection, this routine
  1402. ' Inverts the Colors of the selection region.  Using a DrawMode
  1403. ' of INVERSE, a filled box is drawn over the selected region, which
  1404. ' inverts the colors.
  1405. Private Sub Invert_Selection()
  1406.     Pic_TempImage.DrawMode = INVERSE
  1407.     Pic_Work.DrawMode = INVERSE
  1408.     ' Invert Selected Region.  Do not need to Invert Mask.
  1409.     Pic_TempImage.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1410.     Pic_Work.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1411.     Pic_TempImage.DrawMode = COPY_PEN
  1412.     Pic_Work.DrawMode = COPY_PEN
  1413.     If MovingSelection Then Draw_Selection_Rectangle Else Commit_Selection False
  1414.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  1415. End Sub
  1416.  
  1417. ' Once an object, Line, Square, Filled Square, Circle, or Filled Circle
  1418. ' has been size to what the user wants, this routine is called from the
  1419. ' MouseUp event for the Editing area (Pic_Edit) to display the actual
  1420. ' object.
  1421. Private Sub Line_To_Filled_Circle_MouseUp(X1, Y1, X2, Y2)
  1422.     Pic_Image.DrawWidth = BrushSize
  1423.     Pic_Mask.DrawWidth = BrushSize
  1424.     If CurrentTool = TID_FILLED_SQUARE Or CurrentTool = TID_FILLED_CIRCLE Then
  1425.         Pic_Image.FillStyle = SOLID
  1426.         Pic_Mask.FillStyle = SOLID
  1427.     End If
  1428.     ' Scale the dimensions of the object from the Editing area down
  1429.     ' to that of the Icon, 32x32.
  1430.     Scale_Region True, X1, Y1, X2, Y2, False
  1431.     Select Case CurrentTool
  1432.         Case TID_LINE
  1433.             Pic_Image.Line (X1, Y1)-(X2, Y2)
  1434.             '
  1435.             ' Draw end-point only if BrushSize is one Pixel
  1436.             If BrushSize = 1 Then Pic_Image.PSet (X2, Y2)
  1437.             Pic_Mask.Line (X1, Y1)-(X2, Y2)
  1438.             If BrushSize = 1 Then Pic_Mask.PSet (X2, Y2)
  1439.         Case TID_SQUARE, TID_FILLED_SQUARE
  1440.             Pic_Image.Line (X1, Y1)-(X2, Y2), , B
  1441.             Pic_Mask.Line (X1, Y1)-(X2, Y2), , B
  1442.         Case TID_CIRCLE, TID_FILLED_CIRCLE
  1443.             If Valid_Circle(X1, Y1, X2, Y2) Then
  1444.                 Pic_Image.Circle (XCenter, YCenter), Radius, , , , Aspect
  1445.                 Pic_Mask.Circle (XCenter, YCenter), Radius, , , , Aspect
  1446.                 Radius = 0
  1447.             End If
  1448.     End Select
  1449.     If X1 > X2 Then Swap_Values X1, X2
  1450.     If Y1 > Y2 Then Swap_Values Y1, Y2
  1451.     Pic_Image.DrawWidth = 1
  1452.     Pic_Mask.DrawWidth = 1
  1453.     Pic_Image.FillStyle = TRANSPARENT
  1454.     Pic_Mask.FillStyle = TRANSPARENT
  1455.  
  1456.     ' Only the area modified is redisplayed, which is the rectangle
  1457.     ' defined by the values of X1, Y1, X2, Y2.  If the Brushsize is
  1458.     ' greater than 1 pixel, then the actual area modified is slightly
  1459.     ' larger than the this rectangle, so the values X1, Y1, X2, Y2
  1460.     ' must be adjusted to include the thickness of the Brushsize so
  1461.     ' the entire area modified is redisplayed.
  1462.     '
  1463.     If (BrushSize > 1) And (CurrentTool >= TID_LINE) Then
  1464.         Adjustment = BrushSize \ 2
  1465.         X1 = X1 - Adjustment - 1
  1466.         Y1 = Y1 - Adjustment - 1
  1467.         X2 = X2 + Adjustment + 1
  1468.         Y2 = Y2 + Adjustment + 1
  1469.     End If
  1470.  
  1471. End Sub
  1472.  
  1473. ' For the Line, Square, Filled Square, Circle, and Filled Circle Tools,
  1474. ' an Inverted resizeable version of the object is displayed in response
  1475. ' to a MouseMove.  The object is anchored at the point set by the MouseDown
  1476. ' event within the Editing area.  This routine is called to erase the
  1477. ' old object and display the new object during a MouseMove event.
  1478. '
  1479. Private Sub Line_To_Filled_Circle_Tool_Move(Shift As Integer, X As Single, Y As Single)
  1480. Static LastCircleGood
  1481.  
  1482.     ' Erase Old object
  1483.     '
  1484.     Draw_Line_Or_Box
  1485.     If (CurrentTool >= TID_CIRCLE) And LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1486.     Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_CENTER
  1487.  
  1488.     ' Holding the Shift key down forces a perfect Square or Circle.
  1489.     ' For a line, it forces either a Horizontal, Vertical or 45 degree
  1490.     ' line to be displayed.
  1491.     '
  1492.     If Shift And SHIFT_MASK Then Make_Region_Square
  1493.  
  1494.     If CurrentTool >= TID_CIRCLE Then
  1495.         '
  1496.         ' When sizing a circle, a rectangle with the circle displayed
  1497.         ' within the circle is drawn.  This is done to give a better
  1498.         ' feeling that the mouse is attached to the object when sizing.
  1499.         ' The rectanle is not drawn one the mouse is released.
  1500.         '
  1501.         LastCircleGood = Valid_Circle(X1Region, Y1Region, X2Region, Y2Region)
  1502.         If LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1503.     End If
  1504.  
  1505.     ' Draw New Object
  1506.     '
  1507.     Draw_Line_Or_Box
  1508.  
  1509. End Sub
  1510.  
  1511. ' To make creating a perfect Square, Circle, or a Diagonal, Vertical,
  1512. ' or Horizontal line, the routine is called whenever the Shift key
  1513. ' is depressed in conjuction to dragging the Mouse within the Editing
  1514. ' area.  This routine adjusts the actual mouse coordinates so that
  1515. ' the displayed object is Square, or in the case of a line, Diagonal,
  1516. ' Vertical, or Horizontal.
  1517. '
  1518. Private Sub Make_Region_Square()
  1519.     
  1520.     Xside = Abs(X2Region - X1Region)
  1521.     Yside = Abs(Y2Region - Y1Region)
  1522.     If Xside > Yside Then RectSide = Xside Else RectSide = Yside
  1523.     X2Region = X1Region + RectSide * Sgn(X2Region - X1Region)
  1524.     Y2Region = Y1Region + RectSide * Sgn(Y2Region - Y1Region)
  1525.  
  1526. End Sub
  1527.  
  1528. ' Changes size of brush to either 1x1, 3x3, or 5x5, and
  1529. ' Checks the corresponding Bush menu item
  1530. '
  1531. Private Sub Menu_BrushSelection_Click(Index As Integer)
  1532.   
  1533.     Menu_BrushSelection(BrushSize).Checked = False
  1534.     Menu_BrushSelection(Index).Checked = True
  1535.     BrushSize = Index
  1536.  
  1537. End Sub
  1538.  
  1539. ' Processes all Color Menu selections.
  1540. '
  1541. Private Sub Menu_ColorSelection_Click(Index As Integer)
  1542.     
  1543.     Select Case Index
  1544.  
  1545.         Case MID_COLORS
  1546.             '
  1547.             ' Invoke Custom ColorPalette form
  1548.             '
  1549.             ColorIndex = 0
  1550.             ColorPalette.Show
  1551.  
  1552.         Case MID_DEFAULT_COLORS
  1553.             '
  1554.             ' Default color palette is the same colors as the VB colorpalette
  1555.             '
  1556.             Extract_Colors_From_String DEFAULT_COLORS_ROW1, 0, False
  1557.             Extract_Colors_From_String DEFAULT_COLORS_ROW2, 16, False
  1558.             Extract_Colors_From_String DEFAULT_COLORS_ROW3, 32, True
  1559.         
  1560.         Case MID_SOLID_COLORS
  1561.             '
  1562.             ' Solid colors are the 16 colors returned from QBColors()
  1563.             '
  1564.             Menu_ColorSelection(MID_SOLID_COLORS).Checked = True
  1565.             Show_Solid_Colors_Only
  1566.  
  1567.         Case MID_INI_COLORS
  1568.             '
  1569.             ' If there are Colors saved to the INI file, they will
  1570.             ' be displayed, otherwise, the Default colors will be displayed
  1571.             '
  1572.             Menu_ColorSelection(MID_INI_COLORS).Checked = True
  1573.             Get_INI_File_Colors
  1574.  
  1575.         Case MID_SAVE_COLORS
  1576.             Save_Colors_To_INI_File
  1577.  
  1578.         Case MID_LEFT_RIGHT, MID_SCREEN_INVERSE
  1579.             '
  1580.             ' Same functionality as clicking either of the Mouse Option buttons
  1581.             '
  1582.             Opt_Mouse(Index - MID_LEFT_RIGHT).Value = True
  1583.     
  1584.     End Select
  1585.  
  1586.     ' If the selection was 1 of the 3 colorpalette selections, Check
  1587.     ' the current selection, and Uncheck the previous selection.
  1588.     '
  1589.     If (Index >= MID_DEFAULT_COLORS) And (Index <= MID_INI_COLORS) Then
  1590.         Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = (Index = MID_DEFAULT_COLORS)
  1591.         Menu_ColorSelection(MID_SOLID_COLORS).Checked = (Index = MID_SOLID_COLORS)
  1592.         Menu_ColorSelection(MID_INI_COLORS).Checked = (Index = MID_INI_COLORS)
  1593.     End If
  1594.  
  1595. End Sub
  1596.  
  1597. ' Prepares the Edit menus Sub menu items, by Enabling or Disabling
  1598. ' the menu items depending on whether there is a current selection
  1599. ' or if the current selection is being moved, and the current format
  1600. ' of the system ClipBoard.
  1601. '
  1602. Private Sub Menu_Edit_Click()
  1603.  
  1604.     Menu_EditSelection(MID_CUT).Enabled = Selecting And Not MovingSelection
  1605.     Menu_EditSelection(MID_COPY).Enabled = Selecting And Not MovingSelection
  1606.     Menu_EditSelection(MID_PASTE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1607.     Menu_EditSelection(MID_PASTE_OPAQUE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1608.     Menu_EditSelection(MID_DELETE).Enabled = Selecting And Not MovingSelection
  1609.     Menu_EditSelection(MID_FLIP_HORIZONTAL).Enabled = Selecting
  1610.     Menu_EditSelection(MID_FLIP_VERTICAL).Enabled = Selecting
  1611.     Menu_EditSelection(MID_ROTATE_LEFT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1612.     Menu_EditSelection(MID_ROTATE_RIGHT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1613.     Menu_EditSelection(MID_INVERT).Enabled = Selecting
  1614.  
  1615. End Sub
  1616.  
  1617. ' Processes all Edit Menu selections.
  1618. '
  1619. Private Sub Menu_EditSelection_Click(Index As Integer)
  1620.     Select Case Index
  1621.  
  1622.         Case MID_UNDO
  1623.             UnDo_Edits
  1624.  
  1625.         Case MID_CUT, MID_COPY, MID_DELETE
  1626.             Cut_Copy_Or_Delete_Selection Index
  1627.             
  1628.         Case MID_PASTE, MID_PASTE_OPAQUE
  1629.             Paste_ClipBoard_Contents Index
  1630.  
  1631.         Case MID_SELECT_ALL
  1632.             Select_Entire_Icon
  1633.  
  1634.         Case MID_FLIP_HORIZONTAL, MID_FLIP_VERTICAL
  1635.             Flip_Selection Index
  1636.  
  1637.         Case MID_ROTATE_RIGHT, MID_ROTATE_LEFT
  1638.             Rotate_Selection Index
  1639.  
  1640.         Case MID_INVERT
  1641.             Invert_Selection
  1642.  
  1643.     End Select
  1644.     
  1645. End Sub
  1646.  
  1647. ' Processes all File Menu selections.
  1648. '
  1649. Private Sub Menu_FileSelection_Click(Index As Integer)
  1650.  
  1651.     Select Case Index
  1652.  
  1653.         Case MID_NEW
  1654.             Prepare_For_New_Icon
  1655.       
  1656.         Case MID_OPEN
  1657.             Viewer.Show MODELESS
  1658.  
  1659.         Case MID_SAVE, MID_SAVE_AS
  1660.             Save_Icon Index
  1661.  
  1662.         Case MID_EXIT
  1663.             Unload Editor
  1664.  
  1665.     End Select
  1666.  
  1667. End Sub
  1668.  
  1669. ' Processes all Help Menu selections.
  1670. '
  1671. Private Sub Menu_HelpSelection_Click(Index As Integer)
  1672.  
  1673.     If Index = MID_ABOUT Then
  1674.         AboutBox.Show MODAL
  1675.     Else
  1676.         Get_Help Index
  1677.     End If
  1678.  
  1679. End Sub
  1680.  
  1681. ' Processes all Icons Menu selections.  Same as clicking
  1682. ' one of the Icons within the StatusArea.
  1683. '
  1684. Private Sub Menu_IconsSelection_Click(Index As Integer)
  1685.  
  1686.     Pic_Icons_MouseDown Index, LEFT_BUTTON, 0, 0, 0
  1687.   
  1688. End Sub
  1689.  
  1690. ' Prepares for the Tools sub menu to be shown, by Checking
  1691. ' the currently selected tool.
  1692. '
  1693. Private Sub Menu_Tools_Click()
  1694.  
  1695.     Menu_ToolsSelection(CurrentTool).Checked = True
  1696.  
  1697. End Sub
  1698.  
  1699. ' Processes all Tools Menu selections.  Same as clicking any
  1700. ' tool within the ToolPalette
  1701. '
  1702. Private Sub Menu_ToolsSelection_Click(Index As Integer)
  1703.  
  1704.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, Index * 32
  1705.     
  1706. End Sub
  1707.  
  1708. ' Processes all View Menu selections.
  1709. '
  1710. Private Sub Menu_ViewSelection_Click(Index As Integer)
  1711.  
  1712.     Select Case Index
  1713.  
  1714.         Case MID_STATUS_BAR, MID_TOOL_PALETTE, MID_COLOR_PALETTE, MID_ZOOM_SCROLLBAR, MID_FOCUS, MID_BORDER, MID_POPUP_MENU
  1715.             Menu_ViewSelection(Index).Checked = Not Menu_ViewSelection(Index).Checked
  1716.             If Index = MID_BORDER Then
  1717.                 HighLight_Current_Icon
  1718.             ElseIf Index < MID_FOCUS Then
  1719.                 '
  1720.                 ' Must process a From_Resize to make the Above selection
  1721.                 ' take affect since all hiding and showing of palettes is
  1722.                 ' done within the Form_Resize event.
  1723.                 '
  1724.                 Form_Resize
  1725.             End If
  1726.  
  1727.         Case MID_SHOW_ALL
  1728.             For i = 0 To 3
  1729.                 Menu_ViewSelection(i).Checked = True
  1730.             Next i
  1731.             Form_Resize
  1732.  
  1733.         Case MID_GRID
  1734.             Activate_Grid
  1735.  
  1736.         Case MID_LINE_GRID, MID_DOTTED_GRID
  1737.             Select_Grid_Type Index
  1738.  
  1739.         Case MID_ZOOM_IN
  1740.             Scrl_Zoom.Value = Scrl_Zoom.Value + 32
  1741.  
  1742.         Case MID_ZOOM_OUT
  1743.             Scrl_Zoom.Value = Scrl_Zoom.Value - 32
  1744.       
  1745.     End Select
  1746.   
  1747.     If ((Index = MID_STATUS_BAR) Or (Index = MID_SHOW_ALL)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then Display_Color_Palette Pic_ColorPalette
  1748.  
  1749. End Sub
  1750.  
  1751. ' One of the Mouse Button Options Buttons was selected, so update
  1752. ' the corresponding Color menu items Checked value.
  1753. '
  1754. Private Sub Opt_Mouse_Click(Index As Integer)
  1755.     
  1756.     Menu_ColorSelection(MID_LEFT_RIGHT).Checked = Not (-Index)
  1757.     Menu_ColorSelection(MID_SCREEN_INVERSE).Checked = -Index
  1758.  
  1759. End Sub
  1760.  
  1761. ' The paint tools is the only tool that paints directly to the
  1762. ' Editing area during the MouseMove event.  This routine draws
  1763. ' the pixels to the Icons Image and Mask, and to the Editing area,
  1764. ' so, there is no need to redisplay the modified area of the Icon
  1765. ' in response to a MouseUp event.  However, the StatusArea Icon
  1766. ' will not display the modificatioin until a MouseUp event.
  1767. '
  1768. Private Sub Paint_Tool_Move(Xpix, Ypix)
  1769.                 
  1770.     ' Adjust Mouse position so it is centered within the Pixel being
  1771.     ' drawn.
  1772.     '
  1773.     Adjustment = BrushSize \ 2
  1774.     X1 = Xpix - Adjustment
  1775.     Y1 = Ypix - Adjustment
  1776.     X2 = Xpix + Adjustment
  1777.     Y2 = Ypix + Adjustment
  1778.  
  1779.     ' Draw pixel on Icons Image and Mask
  1780.     '
  1781.     Pic_Image.Line (X1, Y1)-(X2, Y2), , BF
  1782.     Pic_Mask.Line (X1, Y1)-(X2, Y2), , BF
  1783.  
  1784.     ' Draw pixel on Editing area
  1785.     '
  1786.     X2 = X2 + 1
  1787.     Y2 = Y2 + 1
  1788.     Pic_Edit.Line (X1 * PixelSize, Y1 * PixelSize)-(X2 * PixelSize - 1, Y2 * PixelSize - 1), , BF
  1789.  
  1790.     ' Redisplay Grid in modified area if Grid is selected.
  1791.     '
  1792.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  1793.  
  1794. End Sub
  1795.  
  1796. ' In response to an Edit.Paste or Edit.Paste Opaque, this routine is called
  1797. ' to perform the acutal paste operation.  There are two forms of the Paste:
  1798. '
  1799. '   Paste Shift+Ins:  Creates a Mask from the bitmap in the clipboard
  1800. '                     based on the current Screen Color selected.  All
  1801. '                     Pixels in the Bitmap that match the Screen Color
  1802. '                     become transparent.
  1803. '
  1804. '   Paste Opaque Ctrl+Shift+Ins:  No mask is created from the bitmap and
  1805. '                     It is pasted as is with no Screen Color attributes.
  1806. '
  1807. Private Sub Paste_ClipBoard_Contents(Index)
  1808.             
  1809.     ' Get Bitmap from System Clipboard
  1810.     '
  1811.     Pic_Work.Picture = Clipboard.GetData(CF_BITMAP)
  1812.  
  1813.     ' Determine if Bitmap is too large to paste.  Must be 32x32 pixels or
  1814.     ' smaller.
  1815.     '
  1816.     If Pic_Work.Width <= 32 And Pic_Work.Height <= 32 Then
  1817.         '
  1818.         ' Change tool selection to SelectTool, which will allow us to
  1819.         ' move the Bitmap being pasted to anywhere within the Icon.
  1820.         '
  1821.         Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  1822.         
  1823.         Pic_TempImage.Picture = Pic_Work.Image
  1824.         Opaque = MID_PASTE - Index
  1825.  
  1826.         If Opaque Then
  1827.             ' An Opaque paste, so the Bitmap is pasted as is.  So we simply create
  1828.             ' a solid Black mask.
  1829.             '
  1830.             Pic_TempMask.Line (0, 0)-(Pic_TempMask.ScaleWidth, Pic_TempMask.ScaleHeight), BLACK, BF
  1831.         Else
  1832.             ' A normal paste, so a Mask must be created from the Bitmap being pasted,
  1833.             ' based on the currently selected Screen color.  The Mask is created, by
  1834.             ' BitBlt'ing the the 16-color bitmap to a mono Hdc.  All pixels in the color
  1835.             ' bitmap which are the screen color will be white in the monochrome bitmap,
  1836.             ' all others will be black.  That is why the Backcolor of the Picture control
  1837.             ' containing the bitmap is first set to the currently selected Screen color.
  1838.             ' This Monochrome bitmap is then BitBlt'd back to a 16-Color Picture control
  1839.             ' so we can easily manipulate it.
  1840.             '
  1841.             Pic_Work.BackColor = MouseColors(2)
  1842.             R = BitBlt(hDCMono, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCCOPY)
  1843.             R = BitBlt(Pic_TempMask.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, hDCMono, 0, 0, SRCCOPY)
  1844.                     
  1845.             ' Once the Mask is created, all the pixels in the Image bitmap which are of
  1846.             ' currently selected screen color must be changed to Black.  To do this we
  1847.             ' Logically AND the Mask created above with the Image bitmap.  This has the
  1848.             ' affect of turning all pixels which are not the screen color to Black, leaving
  1849.             ' screen color pixels unaffected.  We then XOR the image with this result, which
  1850.             ' gives us the desired result of all screen color pixels of the origianl
  1851.             ' bitmap going to Black, all other pixels are unaffected.
  1852.             '
  1853.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_TempMask.hDC, 0, 0, SRCAND)
  1854.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCINVERT)
  1855.         End If
  1856.  
  1857.         If (Pic_Work.Width = 32) And (Pic_Work.Height = 32) Then
  1858.             ' Bitmap Pasted is too large to allow it to be moved, so we
  1859.             ' commit the Bitmap to the Icon with out allowing it to be
  1860.             ' moved, and then redisplay the Icon.
  1861.             '
  1862.             Scale_Region False, 0, 0, 32, 32, False
  1863.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  1864.             Commit_Selection True
  1865.             Magnify_Icon 0, 0, 31, 31
  1866.         Else
  1867.             ' The Bitmap pasted can be moved, so go into Move mode by setting
  1868.             ' the appropriate flags.
  1869.             '
  1870.             Selecting = True
  1871.             'Moveable = True    ' Read-only in VB5
  1872.             MovingSelection = True
  1873.  
  1874.             ' Set the Selection Region to the size of the Bitmap pasted, in
  1875.             ' both the scale of the Icon and the Magnified Icon.
  1876.             '
  1877.             Scale_Region False, 0, 0, (Pic_Work.Width), (Pic_Work.Height), False
  1878.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  1879.             Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  1880.  
  1881.             ' Redisplay Icon.  Passing a values of 0,0,0,0 simply force the Magnify_Icon
  1882.             ' routine to magnify the pasted Bitmap over the top of the magnified Icon.
  1883.             '
  1884.             Magnify_Icon 0, 0, 0, 0
  1885.         End If
  1886.     Else
  1887.         ' Bitmap was too large to paste, so prompt the user.
  1888.         '
  1889.         Pic_Work.Picture = LoadPicture()
  1890.         MsgBox "ClipBoard image is too large:  " + Format$(Pic_Work.Width) + " x " + Format$(Pic_Work.Height) + CRLF + "Image not pasted", 16, "Error"
  1891.     End If
  1892.  
  1893. End Sub
  1894.  
  1895. ' ColorPalette operations are performed on the MouseUp event,
  1896. ' and DoubleClicking the ColorPalette invokes the Custom
  1897. ' color ColorPalette Form so a flag must be set to inform the
  1898. ' MouseUp event to invoke the Custom ColorPalette form.
  1899. '
  1900. Private Sub Pic_ColorPalette_DblClick()
  1901.  
  1902.     DoubleClicked = True
  1903.  
  1904. End Sub
  1905.  
  1906. ' Checks if Mouse Coordinates are within the ColorPalette, since the mouse
  1907. ' could have been dragged outside of the ColorPalette between the MouseDown
  1908. ' and MouseUp events, in which case the ColorPalette would still get the
  1909. ' MouseUp event with coordinates outside the actual ColorPalette which would
  1910. ' generate and error when accessing the Color Array.
  1911. '
  1912. Private Sub Pic_ColorPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1913.     
  1914.     If (X >= 0) And (X <= 16) And (Y >= 0) And (Y <= 3) Then Update_Mouse_Colors Button, X, Y
  1915.  
  1916. End Sub
  1917.  
  1918. Private Sub Pic_ColorPalette_Paint()
  1919.  
  1920.     Display_Color_Palette Pic_ColorPalette
  1921.  
  1922. End Sub
  1923.  
  1924. ' If the Icon dropped is from the Viewer, it is loaded into the
  1925. ' currently selected Icon, otherwise nothing is done.
  1926. '
  1927. Private Sub Pic_Edit_DragDrop(Ctl As Control, X As Single, Y As Single)
  1928.  
  1929.     If Ctl.Parent.Tag <> Editor.Tag Then Load_An_Icon
  1930.  
  1931. End Sub
  1932.  
  1933. ' If the Icon being dragged is from the Viewer and it has just entered
  1934. ' or left the Edit area, invert the Edit area.
  1935. '
  1936. Private Sub Pic_Edit_DragOver(Ctl As Control, X As Single, Y As Single, State As Integer)
  1937.  
  1938.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then Invert_Control Pic_Edit
  1939.  
  1940. End Sub
  1941.  
  1942. ' A MouseDown event in the Editing area signals the beginning of a new
  1943. ' Tool operation if a tool operation is not already in progress.  All
  1944. ' preparation for the Tool operation is performed here, within the
  1945. ' MouseDown event.
  1946. '
  1947. Private Sub Pic_Edit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1948.  
  1949.     ' Propare for Tool operation only if there is not an operation already in
  1950.     ' progress, and only one mouse button is down, Left or Right.
  1951.     '
  1952.     If (ToolInProcess = 0) And ((Button = LEFT_BUTTON) Or (Button = RIGHT_BUTTON)) Then
  1953.         '
  1954.         ' Save Button value that started Tool Operation.
  1955.         '
  1956.         ToolInProcess = Button
  1957.  
  1958.         Get_Current_Colors Button
  1959.         Pic_Edit.DrawStyle = SOLID
  1960.  
  1961.         If CurrentTool = TID_PAINT Then
  1962.             '
  1963.             ' Begin a Paint tool operation.
  1964.             '
  1965.             Pic_Edit.DrawMode = COPY_PEN
  1966.             
  1967.             ' So a pixel is drawn in repsonse to just a Click within the editing
  1968.             ' area, the MouseMove event must be called since all the actual
  1969.             ' drawing to the Editing area for the Paint Tool is done within the
  1970.             ' MouseMove event.
  1971.             '
  1972.             Pic_Edit_MouseMove Button, 0, X, Y
  1973.  
  1974.         ElseIf CurrentTool <> TID_FILL Then
  1975.             '
  1976.             ' Prepare for all other tools other than Fill and Paint tools.
  1977.             '
  1978.             Pic_Edit.DrawMode = INVERSE
  1979.             If CurrentTool = TID_SELECT Then Adjustment = TO_EDGE Else Adjustment = TO_CENTER
  1980.  
  1981.             ' Determine if a Selection is in process, the Selection can be moved,
  1982.             ' and whether the MousePointer is within the current selection.
  1983.             '
  1984.             If Selecting And Moveable And ((X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region)) Then
  1985.                 '
  1986.                 ' The selection is moveable and the MousePointer is within the
  1987.                 ' selection.  So prepare for a move.
  1988.                 '
  1989.                 Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, Adjustment
  1990.                 If Button = RIGHT_BUTTON Then Opaque = True Else Opaque = False
  1991.  
  1992.                 If Not MovingSelection Then
  1993.                     '
  1994.                     ' The selection has not yet been moved from its original
  1995.                     ' position, so prepare to move selection.
  1996.                     '
  1997.                     ' If the Shift key is down, then the a copy of the Selection
  1998.                     ' will be moved, otherwise the selection will be move from
  1999.                     ' its current location so its previous location must be deleted.
  2000.                     '
  2001.                     If (Shift And SHIFT_MASK) = 0 Then Delete_Selection_From_Icon
  2002.                     Draw_Selection_Rectangle
  2003.                     MovingSelection = True
  2004.                     Draw_Selection_Rectangle
  2005.  
  2006.                 ElseIf (Shift And SHIFT_MASK) Then
  2007.                     '
  2008.                     ' The selection has already been moved from its original
  2009.                     ' location and is being moved again.  If the Shift key is
  2010.                     ' down, make a copy of the selection at its current location
  2011.                     ' and continue the move.
  2012.                     '
  2013.                     Commit_Selection False
  2014.                     Draw_Selection_Rectangle
  2015.                 End If
  2016.             Else
  2017.                 '
  2018.                 ' No selection is in progress, or a selection is in progress
  2019.                 ' but the MousePointer is not within the current selection,
  2020.                 ' or a tool other than the Select tool is in use.
  2021.                 '
  2022.                 ' If a Selection is in progress, commit the Selection at its
  2023.                 ' current location.
  2024.                 '
  2025.                 If Selecting Then Commit_Selection True
  2026.  
  2027.                 ' Prepare for new Tool operation
  2028.                 '
  2029.                 Opaque = True
  2030.                 Adjust_X_and_Y X, Y, X1Region, Y1Region, Adjustment
  2031.                 X2Region = X1Region
  2032.                 Y2Region = Y1Region
  2033.             End If
  2034.         End If
  2035.  
  2036.     End If
  2037.  
  2038. End Sub
  2039.  
  2040. ' For all tools except for the Paint tool and Fill tool, the MouseMove
  2041. ' event is used to size the object to be drawn.  The actual object is
  2042. ' drawn within the MouseUp event based on the coodinates obtained here
  2043. ' in the MouseMove event.  The Paint tool, however, does all of its
  2044. ' actual drawing to the Editing area within the MouseMove event.  The
  2045. ' Fill tool does nothing until the MouseUp event.
  2046. '
  2047. Private Sub Pic_Edit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2048.   
  2049.     ' Calculate pixel mouse is currently over.
  2050.     '
  2051.     Xpix = X \ PixelSize
  2052.     Ypix = Y \ PixelSize
  2053.  
  2054.     ' The Mouse coordinates are always displayed within the StatusArea
  2055.     '
  2056.     Display_Mouse_Coordinates Xpix, Ypix
  2057.  
  2058.     ' Depending on the Current tool, and in the case of the Select tool,
  2059.     ' the state of the Selection, the MousePointer may change.
  2060.     '
  2061.     Set_MousePointer X, Y
  2062.  
  2063.     ' We only want to process the MouseMove event if the Button causing
  2064.     ' the MouseMove event is the same that started the operation.
  2065.     ' The value of the Button that started the operation is stored in
  2066.     ' the global variable ToolInProcess which is set in the MouseDown event.
  2067.     '
  2068.     If (Button = ToolInProcess) And (ToolInProcess <> 0) Then
  2069.     
  2070.         Select Case CurrentTool
  2071.  
  2072.             Case TID_SELECT
  2073.                 Select_Tool_Move Shift, X, Y
  2074.  
  2075.             Case TID_PAINT
  2076.                 Paint_Tool_Move Xpix, Ypix
  2077.  
  2078.             Case TID_LINE To TID_FILLED_CIRCLE
  2079.                 Line_To_Filled_Circle_Tool_Move Shift, X, Y
  2080.  
  2081.         End Select
  2082.  
  2083.     End If
  2084.  
  2085. End Sub
  2086.  
  2087. ' For all tools except for the Paint tool, the actual object drawn
  2088. ' is not drawn until the Mouse Button is released, which is within
  2089. ' the the edit areas MouseUp event.
  2090. '
  2091. Private Sub Pic_Edit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2092.  
  2093.     ' There is no operation that occurs with both mouse buttons down,
  2094.     ' so check to make sure that the MouseUp event is due to the release
  2095.     ' of the same button that started the drawing operation.  The global
  2096.     ' variable ToolInProcess holds the value of the Button.
  2097.     '
  2098.     If Button = ToolInProcess Then
  2099.  
  2100.         Pic_Edit.DrawMode = COPY_PEN
  2101.       
  2102.         Select Case CurrentTool
  2103.     
  2104.             Case TID_SELECT
  2105.                 Select_Tool_MouseUp X1, Y1, X2, Y2
  2106.     
  2107.             Case TID_FILL
  2108.                 Fill_Tool_MouseUp X, Y, X2, Y2
  2109.     
  2110.             Case TID_LINE To TID_FILLED_CIRCLE
  2111.                 Line_To_Filled_Circle_MouseUp X1, Y1, X2, Y2
  2112.     
  2113.         End Select
  2114.  
  2115.         ' The Icon needs to be updated to show the affect of the
  2116.         ' Tool operation for all tools except for the Select tool if
  2117.         ' just making a selection, since all that occurs is a Rectangle
  2118.         ' showing the selection is drawn.
  2119.         '
  2120.         If Not ((CurrentTool = TID_SELECT) And (Not MovingSelection)) Then
  2121.             Update_Icon Pic_Icons(CurrentIcon)
  2122.             '
  2123.             ' Redisplay the Icon for all tools except for the Paint tool.
  2124.             ' The paint tool draws directly on the Edit area within the
  2125.             ' MouseMove event.
  2126.             '
  2127.             If SeletedTool <> TID_PAINT Then Magnify_Icon X1, Y1, X2, Y2
  2128.         End If
  2129.     
  2130.         ToolInProcess = False
  2131.  
  2132.         ' Set enabled state of Edit Menu items.
  2133.         '
  2134.         Menu_Edit_Click
  2135.  
  2136.     End If
  2137.  
  2138. End Sub
  2139.  
  2140. Private Sub Pic_Edit_Paint()
  2141.  
  2142.     ' Repaint Edit area
  2143.     Magnify_Icon 0, 0, 31, 31
  2144.  
  2145. End Sub
  2146.  
  2147. ' If the Icon dropped is from the Viewer, it is loaded into the
  2148. ' StatusArea Icon on which is was dropped and that icon is made
  2149. ' the current Icon, otherwise nothing is done.
  2150. '
  2151. Private Sub Pic_Icons_DragDrop(Index As Integer, Ctl As Control, X As Single, Y As Single)
  2152.  
  2153.     If Ctl.Parent.Tag <> Editor.Tag Then
  2154.         CurrentIcon = Index
  2155.         Load_An_Icon
  2156.     End If
  2157.  
  2158. End Sub
  2159.  
  2160. ' If the Icon being dragged is from the Viewer and it has just entered
  2161. ' or left one of the StatusArea Icons, invert the StatusArea icon.
  2162. '
  2163. Private Sub Pic_Icons_DragOver(Index As Integer, Ctl As Control, X As Single, Y As Single, State As Integer)
  2164.  
  2165.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then
  2166.         Invert_Control Pic_Icons(Index)
  2167.         Pic_Icons(Index).Refresh
  2168.     End If
  2169.  
  2170. End Sub
  2171.  
  2172. ' Clicking on any of the icons within the StatusArea, makes that
  2173. ' Icon the current Icon.  If the the Icon is already the current
  2174. ' Icon, and selection currently in progress is canceled, and
  2175. ' the Icon can be dragged to test what it looks like begin dragged.
  2176. ' It cannot be dropped on anything.
  2177. '
  2178. Private Sub Pic_Icons_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  2179.  
  2180.     ' Determine if new Icon is being selected
  2181.     '
  2182.     If (Button = LEFT_BUTTON) And (Index <> CurrentIcon) Then
  2183.         '
  2184.         ' New Icon has been selected, so prepare for new Icon
  2185.         '
  2186.         Menu_IconsSelection(CurrentIcon).Checked = False
  2187.         Menu_IconsSelection(Index).Checked = True
  2188.         If Selecting Then Commit_Selection True
  2189.         CurrentIcon = Index
  2190.         Select_New_Icon
  2191.     ElseIf (Button = LEFT_BUTTON) And (Index = CurrentIcon) Then
  2192.         '
  2193.         ' The current Icon was selected.
  2194.         '
  2195.         If Selecting Then
  2196.             '
  2197.             ' A selection was in progress so cancel it.
  2198.             '
  2199.             Draw_Selection_Rectangle
  2200.             Selecting = False
  2201.             MovingSelection = False
  2202.             Scale_Region True, X1, Y1, X2, Y2, True
  2203.             Magnify_Icon X1, Y1, X2, Y2
  2204.         End If
  2205.         
  2206.         ' Set the DragIcon of the selected Icon, and begin dragging
  2207.         '
  2208.         Pic_Icons(Index).DragIcon = Pic_Icons(Index).Picture
  2209.         Pic_Icons(Index).Drag
  2210.     End If
  2211.  
  2212. End Sub
  2213.  
  2214. ' Although the StatusArea appears as though it contains many controls
  2215. ' it actually contains only 7 picture controls and 2 Option buttons.
  2216. ' The rest of the information displayed within the StatusArea is painted
  2217. ' directly onto the StatusArea.  This is done to limit the actual number
  2218. ' of controls on the Editor.  The more controls, the more System resources
  2219. ' it uses and the longer it takes to load.  It may be easier to display
  2220. ' certain data using controls, but in some cases, its benificial to not
  2221. ' use controls but display the information yourself.  The easiest controls
  2222. ' to eliminate are Labels since they usually just display text and do
  2223. ' not change throughout the life of the program, and the .Print method
  2224. ' can be used to display the text instead of a label.
  2225. '
  2226. Private Sub Pic_StatusArea_Paint()
  2227.  
  2228.     ' Calculate center of StatusArea
  2229.     '
  2230.     Middle = Pic_StatusArea.ScaleWidth \ 2
  2231.  
  2232.     ' Set font attributes for X & Y Mouse coodinate display
  2233.     '
  2234.     Pic_StatusArea.FontName = "MS Sans Serif"
  2235.     Pic_StatusArea.FontSize = 8.25
  2236.     Pic_StatusArea.ForeColor = BLACK
  2237.  
  2238.     ' Display X & Y mouse coordinate labels, "X=" and Y="
  2239.     '
  2240.     Pic_StatusArea.CurrentY = Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT + 1
  2241.     Pic_StatusArea.CurrentX = (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2242.     Pic_StatusArea.Print "X=";
  2243.     Pic_StatusArea.CurrentX = Middle + (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2244.     Pic_StatusArea.Print "Y=";
  2245.     
  2246.     ' If the Undo Icon is visible, display its label, "Undo to:"
  2247.     '
  2248.     If Pic_Undo.Visible Then
  2249.         Text = "Undo to:"
  2250.         Pic_StatusArea.CurrentX = (Pic_Undo.Left - Pic_StatusArea.TextWidth(Text)) \ 2
  2251.         Pic_StatusArea.CurrentY = Pic_Undo.Top + ((Pic_Undo.Height - Pic_StatusArea.TextHeight(Text)) \ 2)
  2252.         Pic_StatusArea.Print "Undo to:"
  2253.     End If
  2254.     
  2255.     ' If the Mouse Option buttons are visible, then display the the
  2256.     ' option button Color labels and the colors themselves.  The labels are
  2257.     ' all based on the positions of the two Option buttons, so it they
  2258.     ' are moved at design time, the labels will still be displayed
  2259.     ' correctly.
  2260.     '
  2261.     If Opt_Mouse(0).Visible Then
  2262.         '
  2263.         ' Display Mouse Butons header label within a White box with a Black
  2264.         ' outline.
  2265.         '
  2266.         Text = "Mouse Buttons"
  2267.         Y1 = Opt_Mouse(0).Top - 1.25 * Opt_Mouse(0).Height
  2268.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth, Y1 + Pic_StatusArea.TextHeight(Text)), WHITE, BF
  2269.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth - 1, Y1 + Pic_StatusArea.TextHeight(Text)), BLACK, B
  2270.         Pic_StatusArea.CurrentX = (Pic_StatusArea.ScaleWidth - Pic_StatusArea.TextWidth(Text)) \ 2
  2271.         Pic_StatusArea.CurrentY = Y1
  2272.         Pic_StatusArea.FontTransparent = True
  2273.         Pic_StatusArea.Print Text
  2274.         Pic_StatusArea.FontBold = False
  2275.  
  2276.         ' Display the Mouse Button color labels, centered on either
  2277.         ' side of the Option buttons.
  2278.         '
  2279.         For i = 0 To 3
  2280.             Select Case i
  2281.                 Case 0
  2282.                     Text = "Left"
  2283.                 Case 1
  2284.                     Text = "Right"
  2285.                     Shift = Middle
  2286.                 Case 2
  2287.                     Text = "Screen"
  2288.                     Shift = 0
  2289.                 Case 3
  2290.                     Text = "Inverse"
  2291.                     Shift = Middle
  2292.             End Select
  2293.             Pic_StatusArea.CurrentX = Shift + (Middle - Pic_StatusArea.TextWidth(Text)) \ 2
  2294.             Pic_StatusArea.CurrentY = Opt_Mouse(i \ 2).Top - Pic_StatusArea.TextHeight(Text) - 1
  2295.             Pic_StatusArea.Print Text
  2296.         Next i
  2297.  
  2298.         ' Display the 4 color squares showing currently selected colors
  2299.         ' These could be picture controls.
  2300.         '
  2301.         Display_Mouse_Colors
  2302.     End If
  2303.  
  2304.     ' Set StatusArea font attributes back to that of the Mouse coordinates.
  2305.     '
  2306.     Pic_StatusArea.ForeColor = RED
  2307.     Pic_StatusArea.FontName = "Courier"
  2308.     Pic_StatusArea.FontBold = True
  2309.     Pic_StatusArea.FontTransparent = False
  2310.  
  2311.     HighLight_Current_Icon
  2312.  
  2313. End Sub
  2314.  
  2315. ' Performs a "Select All" opertation, just as though the Edit.Select all
  2316. ' menu item was selected.
  2317. '
  2318. Private Sub Pic_ToolPalette_DblClick()
  2319.  
  2320.     If CurrentTool = TID_SELECT Then Menu_EditSelection_Click MID_SELECT_ALL
  2321.  
  2322. End Sub
  2323.  
  2324. ' Prepare for a new tool.  The actual Tool selection is done within
  2325. ' the MouseMove event.
  2326. '
  2327. Private Sub Pic_ToolPalette_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2328.     
  2329.     ' Commit and Selection currently being moved.
  2330.     '
  2331.     If Selecting Then Commit_Selection True
  2332.  
  2333.     ' Commit all edits to Undo Icon
  2334.     '
  2335.     Update_Icon Pic_Undo
  2336.  
  2337.     ' Remove Check from current tool in Tools menu
  2338.     '
  2339.     Menu_ToolsSelection(CurrentTool).Checked = False
  2340.  
  2341.     ' Since the actual selection is done within the MouseMove event, and
  2342.     ' a MouseMove event does not occur until the mouse is moved within
  2343.     ' the ToolPalette, we need to call the MouseMove event, to ensure
  2344.     ' the selected tool is in fact selected, since just clicking on
  2345.     ' the ToolPalette does not generate a MouseMove event.
  2346.     '
  2347.     Pic_ToolPalette_MouseMove Button, Shift, X, Y
  2348.  
  2349. End Sub
  2350.  
  2351. ' Moving the mouse within the ToolPalette after a MouseDown event, will select
  2352. ' the tool the mouse is currently over, so you can slide up and down the palette,
  2353. ' and the tool selection will follow the mouse.
  2354. '
  2355. Private Sub Pic_ToolPalette_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2356.     
  2357.     ' Calculate selected tool.  Each tool Icon is 32 pixels high, so this
  2358.     ' is done easily by Integer dividing the Y coordinate by 32.
  2359.     '
  2360.     NewTool = Y \ 32
  2361.  
  2362.     ' Check to make sure the Mouse is within the Y limits of the ToolPalette
  2363.     ' and not over the currently selected tool.
  2364.     '
  2365.     If (Button <> 0) And (NewTool >= TID_SELECT) And (NewTool <= TID_FILLED_CIRCLE) And (NewTool <> CurrentTool) Then
  2366.         '
  2367.         ' UnHighlight current tool
  2368.         '
  2369.         Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2370.  
  2371.         ' Hightlight new tool
  2372.         '
  2373.         Pic_ToolPalette.Line (0, NewTool * 32 + 1)-(31, NewTool * 32 + 31), , BF
  2374.  
  2375.         CurrentTool = NewTool
  2376.     End If
  2377.   
  2378. End Sub
  2379.  
  2380. Private Sub Pic_ToolPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2381.     
  2382.     ' Set Enabled state of all Edit menu options.
  2383.     '
  2384.     Menu_Edit_Click
  2385.  
  2386. End Sub
  2387.  
  2388. ' The ToolPalette takes care of painting itself since it contains
  2389. ' a single bitmap displaying the Tools.  However, the currently
  2390. ' selected Tool needs to be Hightlighted during the Paint event.
  2391. '
  2392. Private Sub Pic_ToolPalette_Paint()
  2393.     
  2394.     ' Clear ToolPalette to background bitmap of Tools
  2395.     '
  2396.     Pic_ToolPalette.Cls
  2397.  
  2398.     ' HightLight current tool.  The Drawmode of the ToolPalette is
  2399.     ' set to INVERSE, so we simply draw a filled box over the current
  2400.     ' tool.  This inverts the tool.
  2401.     '
  2402.     Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2403.  
  2404. End Sub
  2405.  
  2406. ' Clicking the Undo Icon in the StatusArea is the same thing as
  2407. ' selecting the Edit.Undo menu item.
  2408. '
  2409. Private Sub Pic_Undo_Click()
  2410.  
  2411.     Menu_EditSelection_Click MID_UNDO
  2412.  
  2413. End Sub
  2414.  
  2415. ' In response to a File.New menu opertation, this routine is called,
  2416. ' to prepare creating a new Icon from scratch.
  2417. '
  2418. Private Sub Prepare_For_New_Icon()
  2419.     
  2420.     ' Determine if current Icon has changed since it was saved last and
  2421.     ' and prompt user if it has been changed and not saved.
  2422.     '
  2423.     If Ok_To_Discard_Changes() Then
  2424.         '
  2425.         ' It is ok to prepare for new Icon.
  2426.         
  2427.         ' Terminate any Selection in progress and simulate a Select all,
  2428.         ' then perform an Edit.Delete operation to clear the Icon.
  2429.         '
  2430.         Selecting = False
  2431.         MovingSelection = False
  2432.         Scale_Region False, 0, 0, 32, 32, False
  2433.         Menu_EditSelection_Click MID_DELETE
  2434.  
  2435.         ' Intialize the IconInfo record to default values
  2436.         '
  2437.         ICONINFO(CurrentIcon).FileName = UNTITLED
  2438.         ICONINFO(CurrentIcon).Changed = False
  2439.  
  2440.         ' Reset both the Icon menu and the Editors Titlebar
  2441.         '
  2442.         Menu_IconsSelection(CurrentIcon).Caption = "&" + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2443.  
  2444.         Caption = "IconWorks Editor: " + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2445.     End If
  2446.  
  2447. End Sub
  2448.  
  2449. ' Once a Selection has been made, or an Edit.Select All or Edit.Paste
  2450. ' operation has been made, this routine is called to prepare for a
  2451. ' potential movement of the Selection.  A copy of the actual Icons
  2452. ' Mask and Image are made, and this is the Source from which the
  2453. ' Selection is display whenever the Selection is in fact moved.
  2454. '
  2455. Private Sub Prepare_For_Possible_Move()
  2456.               
  2457.     Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  2458.     Pic_TempImage.Picture = Pic_Image.Image
  2459.     Pic_TempMask.Picture = Pic_Mask.Image
  2460.  
  2461. End Sub
  2462.  
  2463. ' When a selection has been made and the selection is Square, it may
  2464. ' be rotated Left or Right by 90 degrees.  Cannot Rotate a selection
  2465. ' that is being moved.  This routine performs the rotation in repsonse
  2466. ' to an Edit.Rotate Left/Right menu operation.
  2467. '
  2468. Private Sub Rotate_Selection(Index)
  2469.     
  2470.     ' Rotation is not instant, so set Cursor to HourGlass
  2471.     '
  2472.     Screen.MousePointer = HOURGLASS
  2473.  
  2474.     ' Caculate size of Region
  2475.     '
  2476.     NumPixels = X2SelectFrom - X1SelectFrom - 1
  2477.  
  2478.     ' Perform rotation.  The rotation is performed by reading one pixel at
  2479.     ' a time from the source and copying it to is new location in rotated
  2480.     ' either Left or Right 90 degrees.  The Point Method reads the Pixel
  2481.     ' and the Pset method is used to write the pixel.  Both the Icons
  2482.     ' Mask and Image must be rotated.
  2483.     '
  2484.     For Y = 0 To NumPixels
  2485.         For X = 0 To NumPixels
  2486.             If Index = MID_ROTATE_RIGHT Then
  2487.                 '
  2488.                 ' Rotate Right
  2489.                 '
  2490.                 Pic_Image.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2491.                 Pic_Mask.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2492.             Else
  2493.                 ' Rotate Left
  2494.                 '
  2495.                 Pic_Image.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2496.                 Pic_Mask.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2497.             End If
  2498.         Next X
  2499.     Next Y
  2500.  
  2501.     ' Replace Icons Mask and Image with new Mask and Images.
  2502.     '
  2503.     Update_Icon Pic_Icons(CurrentIcon)
  2504.     
  2505.     Prepare_For_Possible_Move
  2506.  
  2507.     ' Redisplay selected region to show rotation.
  2508.     '
  2509.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  2510.  
  2511.     ' Restore Cursor
  2512.     '
  2513.     Screen.MousePointer = DEFAULT
  2514.  
  2515. End Sub
  2516.  
  2517. ' In response to a Color.Save colors to INI file menu operatioin, this
  2518. ' routine is called to write the color values to IconWrks.INI.
  2519. ' WritePrivateProfileString() will create the INI file if it does not
  2520. ' exist, and will create the KeyName if it does not exist in the INI FILE.
  2521. ' The Color values are packed into a single string, one row of colors at
  2522. ' a time, and then written to the INI file.  The colors are formated
  2523. ' into 8-byte fields separated by one space.  After this routine,
  2524. ' IconWrks.INI will contain 3 key entries of:
  2525. '
  2526. '   Colors Row1=16777215 14737632 ...
  2527. '   Colors Row2=12632256 04210752 ...
  2528. '   Colors Row3=08421504 00000000 ...
  2529. '
  2530. Private Sub Save_Colors_To_INI_File()
  2531.     
  2532.     For i = 0 To 2
  2533.         ColorString = ""
  2534.         For C = 0 To 15
  2535.             ColorString = ColorString + Format$(Colors(i * 16 + C), "00000000 ")
  2536.         Next C
  2537.         X = WritePrivateProfileString(APP_NAME, KEY_COLOR + Format$(i + 1), ColorString, INI_FILENAME)
  2538.     Next i
  2539.  
  2540. End Sub
  2541.  
  2542. ' In Response to a File.Save or File.Save As menu operation, this routine
  2543. ' is called to either immediately save the Icon or invoke the SaveFileDlg
  2544. ' to get a Filename to save the Icon to.  A File.Save As operation always
  2545. ' invokes the Dialog, but a File.Save will only invoke the Dialog if the
  2546. ' current icon does not yet have a name, denoted by a name of UNTITLED.
  2547. '
  2548. Private Sub Save_Icon(Index)
  2549.     On Error Resume Next
  2550.     Dim LongName As String
  2551.     Dim Title As String
  2552.     Dim CDPath As String
  2553.  
  2554.     If (Index = MID_SAVE_AS) Or (ICONINFO(CurrentIcon).FileName = UNTITLED) Then
  2555.         ' Set default filter.
  2556.         Editor.CMDialog1.Filter = "Icon Files (*.ico)|*.ico"
  2557.         ' Display Save As dialog.
  2558.         Editor.CMDialog1.FilterIndex = 1
  2559.         Editor.CMDialog1.DefaultExt = "ICO"
  2560.         If Right(ICONINFO(CurrentIcon).FullPath, 1) <> "\" Then
  2561.           Editor.CMDialog1.FileName = ICONINFO(CurrentIcon).FullPath & "\" & ICONINFO(CurrentIcon).FileName
  2562.         End If
  2563.         ' If file has not been saved yet, set common dialog's
  2564.         ' default file name to *.ico
  2565.         If ICONINFO(CurrentIcon).FileName = "[Untitled]" Then
  2566.           Editor.CMDialog1.FileName = "*.ico"
  2567.         End If
  2568.         
  2569.         Editor.CMDialog1.Action = 2
  2570.         ' Exit if user cancels the dialog.
  2571.         If Err = 32755 Then Exit Sub
  2572.         Title = Editor.CMDialog1.FileTitle
  2573.         LongName = Editor.CMDialog1.FileName
  2574.         ICONINFO(CurrentIcon).FullPath = Left(LongName, Len(LongName) - Len(Title))
  2575.         ICONINFO(CurrentIcon).FileName = Editor.CMDialog1.FileTitle
  2576.         ' Adjust for root directory.
  2577.         If Len(ICONINFO(CurrentIcon).FullPath) = 3 Then
  2578.             CDPath = ICONINFO(CurrentIcon).FullPath
  2579.         Else
  2580.             CDPath = Left(LongName, Len(LongName) - Len(Title) - 1)
  2581.         End If
  2582.         ' Change directories for the editor and the viewer.
  2583.         ChDir CDPath
  2584.         Viewer.Dir_DirectoryList.Path = CDPath
  2585.     End If
  2586.         Write_Icon_To_File (ICONINFO(CurrentIcon).FullPath), ICONINFO(CurrentIcon).FileName
  2587. End Sub
  2588.  
  2589. ' When the Editor is terminated, this routine is called to save all
  2590. ' configurable items of the Editor to the IconWrks.INI file.  Size
  2591. ' and Location of the Editor are not saved.
  2592. '
  2593. ' WritePrivateProfileString() will create the INI file and/or any
  2594. ' KeyName that does not exist.
  2595. '
  2596. Private Sub Save_Settings_To_INI_File()
  2597.   
  2598.     R = WritePrivateProfileString(APP_NAME, KEY_GRID, Format$(Abs(Menu_ViewSelection(MID_GRID).Checked)), INI_FILENAME)
  2599.     R = WritePrivateProfileString(APP_NAME, KEY_LINE_GRID, Format$(Abs(Menu_ViewSelection(MID_LINE_GRID).Checked)), INI_FILENAME)
  2600.     R = WritePrivateProfileString(APP_NAME, KEY_DOTTED_GRID, Format$(Abs(Menu_ViewSelection(MID_DOTTED_GRID).Checked)), INI_FILENAME)
  2601.     R = WritePrivateProfileString(APP_NAME, KEY_STATUS_BAR, Format$(Abs(Menu_ViewSelection(MID_STATUS_BAR).Checked)), INI_FILENAME)
  2602.     R = WritePrivateProfileString(APP_NAME, KEY_TOOL_PALETTE, Format$(Abs(Menu_ViewSelection(MID_TOOL_PALETTE).Checked)), INI_FILENAME)
  2603.     R = WritePrivateProfileString(APP_NAME, KEY_COLOR_PALETTE, Format$(Abs(Menu_ViewSelection(MID_COLOR_PALETTE).Checked)), INI_FILENAME)
  2604.     R = WritePrivateProfileString(APP_NAME, KEY_ZOOM_SCROLLBAR, Format$(Abs(Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked)), INI_FILENAME)
  2605.     R = WritePrivateProfileString(APP_NAME, KEY_FOCUS, Format$(Abs(Menu_ViewSelection(MID_FOCUS).Checked)), INI_FILENAME)
  2606.     R = WritePrivateProfileString(APP_NAME, KEY_BORDER, Format$(Abs(Menu_ViewSelection(MID_BORDER).Checked)), INI_FILENAME)
  2607.     R = WritePrivateProfileString(APP_NAME, KEY_POPUP, Format$(Abs(Menu_ViewSelection(MID_POPUP_MENU).Checked)), INI_FILENAME)
  2608.     R = WritePrivateProfileString(APP_NAME, KEY_DEFAULT, Format$(Abs(Menu_ColorSelection(MID_DEFAULT_COLORS).Checked)), INI_FILENAME)
  2609.     R = WritePrivateProfileString(APP_NAME, KEY_SOLID, Format$(Abs(Menu_ColorSelection(MID_SOLID_COLORS).Checked)), INI_FILENAME)
  2610.     R = WritePrivateProfileString(APP_NAME, KEY_INI, Format$(Abs(Menu_ColorSelection(MID_INI_COLORS).Checked)), INI_FILENAME)
  2611.  
  2612. End Sub
  2613.  
  2614. ' Scrolling the Zoom scrollbar Zooms in or Zooms out on the
  2615. ' selected Icon, and maintains it centered within the available
  2616. ' editing space.
  2617. '
  2618. Private Sub Scrl_Zoom_Change()
  2619.     
  2620.     ' Check if new value is multiple of 32 pixels.  Magnified Icon must
  2621.     ' always be increased or decreased my muliples of 32 pixels so the
  2622.     ' Win API routine StretchBlt() can be used to magnify the Icon, and
  2623.     ' the result will be an exact enlargement of the original.
  2624.     '
  2625.     If (Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width Then
  2626.         '
  2627.         ' Scrollbar value is not a multiple of 32, so adjust it so it is.
  2628.         '
  2629.         Scrl_Zoom.Value = Scrl_Zoom.Value - ((Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width)
  2630.     Else
  2631.         ' Scrollbar value is a multiple of 32 pixels.
  2632.         '
  2633.         ' Hide Edit area while resizing and repainting.  It prevents a
  2634.         ' rather annoying visual affect.
  2635.         '
  2636.         Pic_Edit.Visible = False
  2637.  
  2638.         ' Calculate the new size and position values for the Editing area
  2639.         ' and then reposition and resize both the Editing area and the
  2640.         ' temporary Editing area which is used when magnifying the Icon.
  2641.         '
  2642.         MaxLeft = Scrl_Zoom.Left - (Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width)
  2643.         NewLeft = MaxLeft + (ScaleWidth + Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width - MaxLeft - Scrl_Zoom.Value) \ 2
  2644.         NewTop = (ScaleHeight + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height - Scrl_Zoom.Value) \ 2
  2645.         Pic_Edit.Move NewLeft, NewTop, Scrl_Zoom.Value, Scrl_Zoom.Value
  2646.         Pic_EditTemp.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  2647.  
  2648.         ' To allow a selection to be maintained if the Zoom scrollbar is scrolled
  2649.         ' while a selection is in progress, the current selection must be scaled
  2650.         ' down to the scale of the actual Icon, the new PixelSize for the Editing
  2651.         ' area must be calculated, and then the selection is Scaled back to the
  2652.         ' new scale of the Editing area.
  2653.         '
  2654.         If Selecting Then Scale_Region True, X1Region, Y1Region, X2Region, Y2Region, False
  2655.         PixelSize = Pic_Edit.ScaleWidth \ 32
  2656.         If Selecting Then Scale_Region False, X1Region, Y1Region, X2Region, Y2Region, False
  2657.  
  2658.         ' Recreate grid if selected and redisplay the Editing area.
  2659.         '
  2660.         If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  2661.         Pic_Edit.Visible = True
  2662.  
  2663.         ' Set enable state of Zoom in/out View menu items based on new value
  2664.         ' of the Zoom Scrollbar.
  2665.         '
  2666.         Menu_ViewSelection(MID_ZOOM_IN).Enabled = Scrl_Zoom.Value < Scrl_Zoom.Max
  2667.         Menu_ViewSelection(MID_ZOOM_OUT).Enabled = Scrl_Zoom.Value > Scrl_Zoom.Min
  2668.     End If
  2669.  
  2670. End Sub
  2671.  
  2672. ' In response to Double Clicking the Select tool, or an Edit.Select All
  2673. ' menu operation, this routine is called to perform a selection on the
  2674. ' entire Icon, which is the same as if the Entire icon was selected using
  2675. ' the mouse.
  2676. '
  2677. Private Sub Select_Entire_Icon()
  2678.     
  2679.     ' Make the select to the selected tool.  This is neccessary since
  2680.     ' this routine could have been called due to a menu selection, and
  2681.     ' the current tool may not be the Select Tool.
  2682.     '
  2683.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  2684.  
  2685.     ' Make all preparations for a selection just as if it was done
  2686.     ' using the mouse.
  2687.     '
  2688.     Prepare_For_Possible_Move
  2689.     Selecting = True
  2690.     'Moveable = False       ' Read-only in VB5
  2691.     Opaque = True
  2692.     Scale_Region False, 0, 0, 32, 32, False
  2693.     Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  2694.     Draw_Selection_Rectangle
  2695.  
  2696. End Sub
  2697.  
  2698. ' There are two type of grids to choose from when the Grid selection
  2699. ' is active. Line and Dotted grid.  This routine is called in response
  2700. ' to a View.Line Grid or View.Dotted Grid menu operation, to set and
  2701. ' display the selected grid type.  The actual Grid is created in the
  2702. ' Create_Grid procedure.
  2703. '
  2704. Private Sub Select_Grid_Type(Index)
  2705.     
  2706.     ' Check if selected Grid is already the currently selected grid type,
  2707.     ' since there is no need to redisplay it.
  2708.     '
  2709.     If Not Menu_ViewSelection(Index).Checked Then
  2710.         '
  2711.         ' Toggle Checks on Grid type menu items.
  2712.         '
  2713.         Menu_ViewSelection(MID_LINE_GRID).Checked = Not Menu_ViewSelection(MID_LINE_GRID).Checked
  2714.         Menu_ViewSelection(MID_DOTTED_GRID).Checked = Not Menu_ViewSelection(MID_DOTTED_GRID).Checked
  2715.  
  2716.         ' Create the new Grid and redisplay Icon with new Grid.
  2717.         '
  2718.         Create_Grid
  2719.         Magnify_Icon 0, 0, 31, 31
  2720.     End If
  2721.  
  2722. End Sub
  2723.  
  2724. Private Sub Select_Tool_MouseUp(X1, Y1, X2, Y2)
  2725.             
  2726.     ' Erase old Selection rectangle
  2727.     '
  2728.     Draw_Selection_Rectangle
  2729.  
  2730.     ' Adjust selection rectangle so it is completely within the
  2731.     ' editing area.
  2732.     '
  2733.     If X1Region > X2Region Then Swap_Values X1Region, X2Region
  2734.     If Y1Region > Y2Region Then Swap_Values Y1Region, Y2Region
  2735.     If X1Region < 0 Then X1Region = 0
  2736.     If Y1Region < 0 Then Y1Region = 0
  2737.     MaxSize = PixelSize * 32
  2738.     If X2Region > MaxSize Then X2Region = MaxSize
  2739.     If Y2Region > MaxSize Then Y2Region = MaxSize
  2740.  
  2741.     If MovingSelection Then
  2742.         '
  2743.         ' The selection is being moved, so all that needs to be done is
  2744.         ' to update the values containing the last location of the
  2745.         ' selection, which are used when the selection is moved.
  2746.         '
  2747.         X1 = LastX1
  2748.         Y1 = LastY1
  2749.         X2 = LastX2
  2750.         Y2 = LastY2
  2751.  
  2752.     ElseIf (X1Region <> X2Region) And (Y1Region <> Y2Region) Then
  2753.         '
  2754.         ' A new selection has been made
  2755.         '
  2756.         Prepare_For_Possible_Move
  2757.         Selecting = True
  2758.         Opaque = True
  2759.  
  2760.         ' Determine if selection can be moved.  The selection cannot be moved
  2761.         ' if it consists of the entire icon.
  2762.         '
  2763.         ' Moveable = ((X2Region - X1Region) < Pic_Edit.ScaleWidth) Or ((Y2Region - Y1Region) < Pic_Edit.ScaleWidth)
  2764.  
  2765.         Draw_Selection_Rectangle
  2766.         Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  2767.     End If
  2768.     Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  2769.  
  2770. End Sub
  2771.  
  2772. ' A move event using the Select tool, can do one of three things,
  2773. ' size the selection rectangle to make the selection, move the
  2774. ' current selection, or copy the current selection to another
  2775. ' location.  This routine either draws the selection rectangle
  2776. ' as the selection is being made or moves/copies the current
  2777. ' selection.
  2778. '
  2779. Private Sub Select_Tool_Move(Shift As Integer, X As Single, Y As Single)
  2780.  
  2781.     ' Erase old selection rectangle
  2782.     '
  2783.     Draw_Selection_Rectangle
  2784.  
  2785.     If MovingSelection Then
  2786.         '
  2787.         ' Calculate new location of Selection rectangle.
  2788.         '
  2789.         XLastMove = XMoveSelection
  2790.         YLastMove = YMoveSelection
  2791.         Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, TO_EDGE
  2792.         X1Region = X1Region + (XMoveSelection - XLastMove)
  2793.         X2Region = X2Region + (XMoveSelection - XLastMove)
  2794.         Y1Region = Y1Region + (YMoveSelection - YLastMove)
  2795.         Y2Region = Y2Region + (YMoveSelection - YLastMove)
  2796.  
  2797.         ' Prevent Selection from being moved of the left or right
  2798.         ' of the editing area
  2799.         '
  2800.         If (X1Region < 0) Or (X2Region > (32 * PixelSize)) Then
  2801.             X1Region = X1Region - (XMoveSelection - XLastMove)
  2802.             X2Region = X2Region - (XMoveSelection - XLastMove)
  2803.         End If
  2804.         
  2805.         ' Prevent Selection from being moved of the top or bottom
  2806.         ' of the editing area
  2807.         '
  2808.         If (Y1Region < 0) Or Y2Region > (32 * PixelSize) Then
  2809.             Y1Region = Y1Region - (YMoveSelection - YLastMove)
  2810.             Y2Region = Y2Region - (YMoveSelection - YLastMove)
  2811.         End If
  2812.     Else
  2813.         ' A selection is being made, so adjust the mouse coordinates
  2814.         ' to the Edge of the pixels so the rectangle is completely
  2815.         ' around the selction.
  2816.         '
  2817.         Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_EDGE
  2818.  
  2819.         ' Make the Selection perfectly square if the Shift key is down
  2820.         '
  2821.         If Shift And SHIFT_MASK Then Make_Region_Square
  2822.     End If
  2823.  
  2824.     ' Draw the new selection recangle
  2825.     '
  2826.     Draw_Selection_Rectangle
  2827.  
  2828. End Sub
  2829.  
  2830. ' When the MousePointer is within the Editing area, the MousePointer
  2831. ' is changed depending on the Tool being used.  This routine is called
  2832. ' from the MouseMove event for the Editing area (Pic_Edit) to change
  2833. ' the MousePointer.
  2834. '
  2835. Private Sub Set_MousePointer(X As Single, Y As Single)
  2836.     
  2837.     If Selecting And Moveable And (X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region) Then
  2838.         '
  2839.         ' A selection is in progress and the selection is moveable,
  2840.         ' and the MousePointer is within the the selection, so the
  2841.         ' MousePointer is changed to a SIZE pointer to indacte
  2842.         ' that the Selection can be moved.
  2843.         '
  2844.         Pic_Edit.MousePointer = SIZE
  2845.     ElseIf (CurrentTool = TID_PAINT) Or (CurrentTool = TID_FILL) Then
  2846.         Pic_Edit.MousePointer = UP_ARROW
  2847.     Else
  2848.         Pic_Edit.MousePointer = CROSSHAIR
  2849.     End If
  2850.  
  2851. End Sub
  2852.  
  2853. ' Since some of the tools can only use Solid colors and not Dithered
  2854. ' colors, it is useful to have the option of displayin only the solid
  2855. ' colors within the ColorPalette.  This routine changes the Color
  2856. ' array to contain only Solid color values then redisplays the
  2857. ' ColorPalette.  There are still 3 rows of colors, but each color
  2858. ' cell in the same column are set to the same solid color.
  2859. '
  2860. Private Sub Show_Solid_Colors_Only()
  2861.     
  2862.     ' Set Color array to all solid colors returned from QBColors()
  2863.     '
  2864.     For i = 0 To 15
  2865.         Colors(i) = QBColor(i)
  2866.         Colors(i + 16) = QBColor(i)
  2867.         Colors(i + 32) = QBColor(i)
  2868.     Next
  2869.  
  2870.     ' Redisplay ColorPalettes.
  2871.     '
  2872.     Display_Color_Palette Pic_ColorPalette
  2873.     If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  2874.  
  2875. End Sub
  2876.  
  2877. ' This routine is called in response to an Edit.Undo menu operation.
  2878. ' The Icon displayed in the Undo Icon within the StatusArea is
  2879. ' Copied to the Selected Icon.
  2880. '
  2881. Private Sub UnDo_Edits()
  2882.     
  2883.     ' Terminate any Select or Move opteration
  2884.     '
  2885.     Selecting = False
  2886.     MovingSelection = False
  2887.  
  2888.     ' Get Image and Mask of Icon displayed in Undo Icon in StatusArea
  2889.     '
  2890.     Extract_Image_And_Mask Pic_Undo
  2891.  
  2892.     ' Copy Undo Icons Mask and Image to selected icon
  2893.     '
  2894.     Update_Icon Pic_Icons(CurrentIcon)
  2895.  
  2896.     ' Redisplay entire icon
  2897.     '
  2898.     Magnify_Icon 0, 0, 31, 31
  2899.  
  2900. End Sub
  2901.  
  2902. ' When using either the Circle or Filled Circle tool, this routine is called
  2903. ' to verify that the resulting circle from the current Mouse coordinates is
  2904. ' a valid circle, since in some cases the result would be a vertical or
  2905. ' horizontal line which would generate and "Division by Zero" if not checked
  2906. ' for.  If the Circle is valid, this routine calculates and sets the Global
  2907. ' values of XCenter, YCenter, and Raduis for new Circle.
  2908. '
  2909. Private Function Valid_Circle(X1, Y1, X2, Y2)
  2910.           
  2911.     Xleg = Abs(X2 - X1)
  2912.     If Xleg <> 0 Then
  2913.         Yleg = Abs(Y2 - Y1)
  2914.         Aspect = Abs(Yleg / Xleg)
  2915.         If Xleg > Yleg Then Radius = Xleg / 2 Else Radius = Yleg / 2
  2916.         XCenter = X1 + (X2 - X1) / 2
  2917.         YCenter = Y1 + (Y2 - Y1) / 2
  2918.     End If
  2919.  
  2920.     ' Return value of XLeg at Function value, since if XLeg is non-zero,
  2921.     ' (True) it is a valid circle, and if XLeg is zero (False) it is
  2922.     ' an Invalid circle.
  2923.     '
  2924.     Valid_Circle = Xleg
  2925.  
  2926. End Function
  2927.  
  2928.